Code
/// <summary>
/// 插入缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
public static void Insert(string key, object obj)
{
Insert(key,obj,null,1);
}
/// <summary>
/// 插入缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
/// <param name="dep">CacheDependency对象</param>
public static void Insert(string key, object obj, CacheDependency dep)
{
Insert(key,obj,dep,MinuteFactor * 3);
}
/// <summary>
/// 插入缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
/// <param name="seconds">缓存时间(单位:秒)</param>
public static void Insert(string key, object obj, int seconds)
{
Insert(key,obj,null,seconds);
}
/// <summary>
/// 插入缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
/// <param name="seconds">缓存时间(单位:秒)</param>
/// <param name="priority">优先级</param>
public static void Insert(string key, object obj, int seconds, CacheItemPriority priority)
{
Insert(key,obj,null,seconds,priority);
}
/// <summary>
/// 插入缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
/// <param name="dep">CacheDependency对象</param>
/// <param name="seconds">缓存时间(单位:秒)</param>
public static void Insert(string key, object obj, CacheDependency dep, int seconds)
{
Insert(key,obj,dep,seconds,CacheItemPriority.Normal);
}
/// <summary>
/// 插入缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
/// <param name="dep">CacheDependency对象</param>
/// <param name="seconds">缓存时间(单位:秒)</param>
/// <param name="priority">优先级</param>
public static void Insert(string key, object obj, CacheDependency dep, int seconds, CacheItemPriority priority)
{
if(obj != null)
{
_cache.Insert(key,obj,dep,DateTime.Now.AddSeconds(Factor * seconds), TimeSpan.Zero,priority,null);
}
}
/// <summary>
/// 插入生存周期短的缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
/// <param name="secondFactor">缓存时间(单位:秒)</param>
public static void MicroInsert (string key, object obj, int secondFactor)
{
if(obj != null) {
_cache.Insert(key,obj,null,DateTime.Now.AddSeconds(Factor * secondFactor), TimeSpan.Zero);
}
}
/// <summary>
/// 插入生存周期长的缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
public static void Max(string key, object obj)
{
Max(key,obj,null);
}
/// <summary>
/// 插入生存周期长的缓存项目
/// </summary>
/// <param name="key">键值</param>
/// <param name="obj">要插入缓存的对象</param>
/// <param name="dep">CacheDependency对象</param>
public static void Max(string key, object obj, CacheDependency dep)
{
if(obj != null)
{
_cache.Insert(key,obj,dep,DateTime.MaxValue,TimeSpan.Zero,CacheItemPriority.AboveNormal,null);
}
}