Пример #1
0
 public void Set(string key, object value, string fileName)
 {
     if (File.Exists(fileName))
     {
         FileInfo   fileInfo = new FileInfo(fileName);
         CacheModel cache    = new CacheModel();
         cache.cacheFile     = fileName;
         cache.lastWriteTime = fileInfo.LastWriteTime;
         cache.Value         = value;
         if (!this.Contains(key))
         {
             _cacheDic.Add(key, cache);
         }
         else
         {
             _cacheDic[key] = cache;
         }
     }
 }
Пример #2
0
 public void Set(string key, object value, double time)
 {
     lock (cacheObj)
     {
         if (!this.Contains(key))
         {
             CacheModel cacheModel = new CacheModel();
             cacheModel.Value   = value;
             cacheModel.expTime = DateTime.Now.AddMinutes(time);
             _cacheDic.Add(key, cacheModel);
         }
         else
         {
             CacheModel cacheModel = new CacheModel();
             cacheModel.Value   = value;
             cacheModel.expTime = DateTime.Now.AddMinutes(time);
             _cacheDic[key]     = cacheModel;
         }
         if (time == -1)
         {
             notExpire.Add(key);
         }
     }
 }