本文整理汇总了C#中CacheType类的典型用法代码示例。如果您正苦于以下问题:C# CacheType类的具体用法?C# CacheType怎么用?C# CacheType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheType类属于命名空间,在下文中一共展示了CacheType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cache
public static void Cache(Product product, CacheType cacheType)
{
if (!string.IsNullOrEmpty(product.UPC)
&& !upcProductDic.ContainsKey(product.UPC))
{
upcProductDic.Add(product.UPC, new ProductWraper()
{
CacheType = cacheType,
Product = product,
LastUsedTime = DateTime.Now
});
}
if (!string.IsNullOrEmpty(product.AmazonASIN)
&& !amazonAsinProductDic.ContainsKey(product.AmazonASIN))
{
amazonAsinProductDic.Add(product.AmazonASIN, new ProductWraper()
{
CacheType = cacheType,
Product = product,
LastUsedTime = DateTime.Now
});
}
if (!string.IsNullOrEmpty(product.BestBuySKU)
&& !bestBuySkuProductDic.ContainsKey(product.BestBuySKU))
{
bestBuySkuProductDic.Add(product.BestBuySKU, new ProductWraper()
{
CacheType = cacheType,
Product = product,
LastUsedTime = DateTime.Now
});
}
}
示例2: SchemaTable
/// <summary>
///
/// </summary>
/// <param name="accessLevel">访问级别</param>
/// <param name="cacheType">缓存的类型</param>
/// <param name="isStoreInDb">是否存储到DB</param>
public SchemaTable(AccessLevel accessLevel, CacheType cacheType, bool isStoreInDb)
{
AccessLevel = accessLevel;
CacheType = cacheType;
Keys = new string[0];
_columns = new ConcurrentDictionary<string, SchemaColumn>();
}
示例3: GetItem
/// <summary>
///
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static Object GetItem(CacheType type)
{
switch (type)
{
case CacheType.TopCatalog:
if (QJVRMSCache.Get(type.ToString()) == null)
{
QJVRMSCache.Insert(type.ToString(), Catalog.GetTopCatalog());
}
break;
case CacheType.AllCatalog:
if (QJVRMSCache.Get(type.ToString()) == null)
{
QJVRMSCache.Insert(type.ToString(), Catalog.GetAllCatalog());
}
break;
case CacheType.Feature:
break;
case CacheType.ResouceType:
if (QJVRMSCache.Get(type.ToString()) == null)
{
QJVRMSCache.Insert(type.ToString(), ResourceTypeManager.GetTypeList());
}
break;
default:
break;
}
return QJVRMSCache.Get(type.ToString());
}
示例4: CacheSettings
public TimeSpan SlidingExpritationPeriod { get; set; } // Has sense for AspNet/Mixed cache
public CacheSettings(CacheType cacheType)
{
CacheType = cacheType;
SlidingExpritationPeriod = TimeSpan.Zero;
DefaultPriority = CachePriority.Default;
Size = -1; // Unlimited
}
示例5: SaveCache
public async Task<bool> SaveCache(string stringToStore, CacheType type)
{
var fileName = type.GetFileNameFromCacheType();
try
{
StorageFile file;
// Check if file exist in local folder and if it does replace it
// C:\Users\three\AppData\Local\Packages\c49b095b-93a9-472f-a151-0629a4c64267_a9ekxv88vhe1y\LocalState
if (type == CacheType.SettingsData)
{
file = await LocalRoamingFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
}
else
{
file = await LocalCacheFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
}
// Write file to folder
await FileIO.WriteTextAsync(file, stringToStore);
return true;
}
catch
{
return false;
}
}
示例6: CachedItem
public CachedItem(object value, CacheType cacheType, TimeSpan increment)
{
Value = value;
CacheType = cacheType;
Increment = increment;
if (cacheType.IsDefined())
{ Expiration = DateTime.Now.Add(increment); }
}
示例7: Invalidate
/// <summary>
/// Invalidate the image corresponding to given parameters from given caches.
/// </summary>
/// <param name="parameters">Image parameters.</param>
/// <param name="cacheType">Cache type.</param>
public static void Invalidate(this TaskParameter parameters, CacheType cacheType)
{
using (var task = CreateTask(parameters, null))
{
var key = task.GetKey();
ImageService.Invalidate(key, cacheType);
}
}
示例8: InvalidateAsync
/// <summary>
/// Invalidate the image corresponding to given parameters from given caches.
/// </summary>
/// <param name="parameters">Image parameters.</param>
/// <param name="cacheType">Cache type.</param>
public static async Task InvalidateAsync(this TaskParameter parameters, CacheType cacheType)
{
var target = new Target<WriteableBitmap, ImageLoaderTask>();
using (var task = CreateTask(parameters, target))
{
var key = task.GetKey();
await ImageService.Instance.InvalidateCacheEntryAsync(key, cacheType).ConfigureAwait(false);
}
}
示例9: CacheInstance
public static ICacheService CacheInstance(CacheType cacheType)
{
switch (cacheType)
{
case CacheType.LocalMemory:
return new LocalMemoryCacheService();
default:
throw new ArgumentException("Invalid cache type or cache type does not have implementation");
}
}
示例10: CacheMap
/// <summary>
/// Returns a caching map for the given input map.
/// </summary>
internal static IZoneIntervalMap CacheMap([NotNull] IZoneIntervalMap map, CacheType type)
{
switch (type)
{
case CacheType.Hashtable:
return new HashArrayCache(map);
default:
throw new ArgumentException("The type parameter is invalid", "type");
}
}
示例11: CacheCommandLogEntry
public CacheCommandLogEntry(OperationContext context, string commandName, object[] args, DateTime dateTime, long executionTime, int rowCount, CacheType cacheType)
: base(LogEntryType.Command, context, dateTime)
{
_commandName = commandName;
_args = args;
_dateTime = dateTime;
_executionTime = executionTime;
_rowCount = rowCount;
_cacheType = cacheType;
}
示例12: AddCachedTypes
public void AddCachedTypes(CacheType cacheType, params Type[] entities)
{
if(entities == null || entities.Length == 0)
return;
switch(cacheType) {
case CacheType.None: break;
case CacheType.LocalSparse: this.LocalSparseCacheTypes.UnionWith(entities); break;
case CacheType.Sparse: this.SparseCacheTypes.UnionWith(entities); break;
case CacheType.FullSet: this.FullSetCacheTypes.UnionWith(entities); break;
}
}
示例13: CacheItemSet
/// <summary>
///
/// </summary>
/// <param name="cacheItemType"></param>
/// <param name="periodTime"></param>
/// <param name="isReadOnly"></param>
public CacheItemSet(CacheType cacheItemType, int periodTime, bool isReadOnly)
{
LoadingStatus = LoadingStatus.None;
_cacheItemType = cacheItemType;
_isReadOnly = isReadOnly;
if (periodTime > 0)
{
_period = new CachePeriod(periodTime);
}
}
示例14: Extensions
public void Extensions(CacheType cacheType)
{
var cache = GetCache(cacheType, 3);
cache.Add(1, 10);
cache.Add(2, 20);
cache.Add(3, 30);
Assert.AreEqual(10, cache.Get(1));
Assert.AreEqual(20, cache.Get(2));
Assert.AreEqual(30, cache.Get(3));
}
示例15: Basic
public void Basic(CacheType cacheType)
{
var cache = GetCache(cacheType, 3);
cache[1] = 10;
cache[2] = 20;
cache[3] = 30;
Assert.AreEqual(10, cache[1]);
Assert.AreEqual(20, cache[2]);
Assert.AreEqual(30, cache[3]);
}