Ejemplo n.º 1
0
 public static void Add(string key, object value)
 {
     if (cache != null)
     {
         cache.Add(key, value);
     }
 }
Ejemplo n.º 2
0
        public static void Set <T>(string key,
                                   T value)
        {
            if (_cache.Contains(key))
            {
                _cache.Remove(key);
            }

            if (value != null)
            {
                _cache.Add(key, value);
            }
        }
Ejemplo n.º 3
0
 private void InitCache()
 {
     cacheMgr = (CacheManager)CacheFactory.GetCacheManager();
     
     //string file = Path.Combine(HttpRuntime.AppDomainAppPath, "stateserver.state");
     //Stream s = null;
     //try
     //{
     //    if (File.Exists(file))
     //    {
     //        log.Debug("Analyzing StateServer persistance...");
     //        s = File.Open(file, FileMode.Open);
     //        BinaryFormatter bf = new BinaryFormatter();
     //        List<LineControl> lineControls = (List<LineControl>)bf.Deserialize(s);
     //        log.Debug(lineControls.Count + " lines retreived...");
         foreach (LineControl lc in SnapshotService.GetSnapshot())
             {
                 log.Debug("Adding " + lc.directoryNumber + " to the cache.");
                 cacheMgr.Add(lc.directoryNumber, lc);
             }
     //        s.Close();
     //        s.Dispose();
     //    }
     //}
     //catch (Exception ex)
     //{
     //    log.Error("Unable to initialize cache: " + ex.Message);
     //}
     //finally
     //{
     //    if (s != null)
     //    {
     //        s.Close();
     //        s.Dispose();
     //    }
     //}
 }