WEB开发网
开发学院WEB开发ASP.NET .NET缓存类和说明 阅读

.NET缓存类和说明

 2012-04-05 09:00:38 来源:WEB开发网   
核心提示:/** * 使用时间偏差内的缓存的意思是在缓存创建后slidingExpiration时间偏差内连续访问缓存项的话继续保持指定缓存项对象 * 用 偏差 过期的缓存absoluteExpiration参数要设置NoAbsoluteExpiration,NoAbsoluteExpiration是DateTime.MaxVa
/*
* 使用时间偏差内的缓存的意思是在缓存创建后slidingExpiration时间偏差内连续访问缓存项的话继续保持指定缓存项对象
 * 用 偏差 过期的缓存absoluteExpiration参数要设置NoAbsoluteExpiration,NoAbsoluteExpiration是DateTime.MaxValue的意思
* 就要slidingExpiration时间偏差内连续访问的话连续缓存,如果在slidingExpiration时间偏差内没人用缓存项拿删除
* static Cache()
{
NoAbsoluteExpiration = DateTime.MaxValue;
NoSlidingExpiration = TimeSpan.Zero;
s_sentinelRemovedCallback = new CacheItemRemovedCallback(SentinelEntry.OnCacheItemRemovedCallback);
}
*/
/// <summary>
/// 在指定的slidingExpiration时间偏差内连续访问缓存项的话(级别Normal = 3),继续保持指定缓存项对象里加入对象
/// 别的级别(NotRemovable = 6,High = 5,AboveNormal = 4,Normal = 3,BelowNormal = 2,Low = 1)
/// absoluteExpiration=NoAbsoluteExpiration,slidingExpiration=TimeSpan.FromSeconds(expire)
/// </summary>
/// <param name="CacheKey">对象的键值</param>
/// <param name="o">缓存的对象</param>
/// <param name="expire">时间偏差</param>
public static void InsertNormalSlidingCache(string CacheKey, object o, int expire)
{
if (CacheKey == null || CacheKey.Length == 0 || o == null)
{
return;
}
webCache.Insert(CacheKey, o, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(expire), CacheItemPriority.Normal, null);
}
/// <summary>
/// 在指定的slidingExpiration时间偏差内连续访问缓存项的话(高级别High = 5),继续保持指定缓存项对象里加入对象
/// 别的级别(NotRemovable = 6,High = 5,AboveNormal = 4,Normal = 3,BelowNormal = 2,Low = 1)
/// absoluteExpiration=NoAbsoluteExpiration,slidingExpiration=TimeSpan.FromSeconds(expire)
/// </summary>
/// <param name="CacheKey">对象的键值</param>
/// <param name="o">缓存的对象</param>
/// <param name="expire">时间偏差</param>
public static void InsertHighSlidingCache(string CacheKey, object o, int expire)
{
if (CacheKey == null || CacheKey.Length == 0 || o == null)
{
return;
}
webCache.Insert(CacheKey, o, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(expire), CacheItemPriority.High, null);
}
/// <summary>
/// 在指定的absoluteExpiration时间偏差内连续访问缓存项的话,继续保持指定缓存项对象里加入对象
/// absoluteExpiration=NoAbsoluteExpiration,absoluteExpiration=TimeSpan.FromSeconds(expire)
/// </summary>
/// <param name="CacheKey">对象的键值</param>
/// <param name="o">缓存的对象</param>
/// <param name="expire">时间偏差</param>

上一页  1 2 3 4  下一页

Tags:NET 缓存 说明

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接