本文整理汇总了C#中System.Runtime.Caching.CacheItem.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CacheItem.ToString方法的具体用法?C# CacheItem.ToString怎么用?C# CacheItem.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Caching.CacheItem
的用法示例。
在下文中一共展示了CacheItem.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveCache
/// <summary>
/// Removes the data associated with the <paramref name="cacheItemId"/> from the cache.
/// </summary>
/// <param name="cacheItemId">The cache item ID for the cache item.</param>
public static void RemoveCache(CacheItem cacheItemId)
{
CacheManager.Remove(cacheItemId.ToString());
}
示例2: SetCache
/// <summary>
/// Adds the <paramref name="cacheItem"/> to the cache named <paramref name="cacheItemId"/> and set to an absolute expiration
/// time specified in <paramref name="dateTimeOffset"/>. If it exists it is overwritten.
/// If <paramref name="cacheItem"/> is null, any existing cache named <paramref name="cacheItemId"/> is deleted.
/// If caching is disabled (<see cref="IAppSetting.EnableCache" />=<c>false</c>), then no action is taken.
/// </summary>
/// <param name="cacheItemId">The cache item ID for the cache item.</param>
/// <param name="cacheItem">The item to be stored in cache.</param>
/// <param name="dateTimeOffset">The fixed date and time at which the cache entry will expire.</param>
public static void SetCache(CacheItem cacheItemId, object cacheItem, DateTimeOffset dateTimeOffset)
{
if (!AppSetting.Instance.EnableCache)
return;
if (cacheItem != null)
{
CacheManager.Add(cacheItemId.ToString(), cacheItem, dateTimeOffset);
}
else
{
CacheManager.Remove(cacheItemId.ToString());
}
}
示例3: GetCache
/// <summary>
/// Gets the data stored in cache that has the name <paramref name="cacheItemId"/>. Returns null if no data is in the cache.
/// </summary>
/// <param name="cacheItemId">The cache item ID for the cache item.</param>
/// <returns>Returns the data stored in cache that has the name <paramref name="cacheItemId"/>.</returns>
public static object GetCache(CacheItem cacheItemId)
{
return CacheManager.Get(cacheItemId.ToString());
}