Exemple #1
0
 /// <summary>
 /// 添加缓存值 当容器中不存在key值时添加
 /// </summary>
 /// <param name="argKey">key值</param>
 /// <param name="argValue">value值</param>
 /// <param name="expiration">过期时间</param>
 /// <returns></returns>
 public int Add(object argKey, object argValue, DateTime expiration)
 {
     lock (_object)
     {
         if (Dic != null && !Dic.ContainsKey(argKey))
         {
             CacheBody body = new CacheBody() { Body = argValue, Expiration = expiration, DependencyFile = string.Empty };
             Dic.Add(argKey, body);
             return 1;
         }
         return 0;
     }
 }
Exemple #2
0
 /// <summary>
 /// 添加缓存值 当容器中不存在key值时添加
 /// 当容器中存在key值修改
 /// </summary>
 /// <param name="argKey">key值</param>
 /// <param name="argValue">value值</param>
 /// <returns></returns>
 public int Insert(object argKey, object argValue)
 {
     lock (_object)
     {
         if (Dic != null)
         {
             if (Dic.ContainsKey(argKey))
             {
                 Dic[argKey].Body = argValue;
             }
             else
             {
                 CacheBody body = new CacheBody() { Body = argValue, Expiration = DateTime.MaxValue, DependencyFile = string.Empty };
                 Dic.Add(argKey, body);
             }
             return 1;
         }
         return 0;
     }
 }