Esempio n. 1
0
File: RestCache.cs Progetto: xqgzh/Z
 /// <summary>
 /// 读取当前应用下的restCache.config文件初始化缓存
 /// </summary>
 static RestCache()
 {
     try
     {
         var configFile = FileTools.FindFile("restCache.config");
         if (configFile == null)
         {
             Enable = false;
             logger.Error("Cannot find the configuration for RestCache");
             configuration = new RestCacheConfiguration();
             configuration.CacheItems = new List<CacheItem>();
         }
         else
         {
             configuration = Z.C.AppConfigHandler.GetConfig<RestCacheConfiguration>(configFile.FullName);
             if (configuration.CacheType == CACHE_TYPE_MEMCACHED)
             {
                 Enable = true;
                 cacheManager = new MemcachedManager(configuration.PoolSet);
             }
             else if (configuration.CacheType == CACHE_TYPE_ASPNET)
             {
                 Enable = true;
                 cacheManager = new DotNetCacheManager();
             }
             else if (configuration.CacheType == CACHE_TYPE_COUCH)
             {
                 Enable = true;
                 cacheManager = new CouchCacheManager();
             }
         }
     }
     catch (Exception e)
     {
         Enable = false;
         logger.Error(e);
         configuration = new RestCacheConfiguration();
         configuration.CacheItems = new List<CacheItem>();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 读取当前应用下的restCache.config文件初始化缓存
 /// </summary>
 static RestCache()
 {
     try
     {
         var configFile = FileTools.FindFile("restCache.config");
         if (configFile == null)
         {
             Enable = false;
             logger.Error("Cannot find the configuration for RestCache");
             configuration            = new RestCacheConfiguration();
             configuration.CacheItems = new List <CacheItem>();
         }
         else
         {
             configuration = Z.C.AppConfigHandler.GetConfig <RestCacheConfiguration>(configFile.FullName);
             if (configuration.CacheType == CACHE_TYPE_MEMCACHED)
             {
                 Enable       = true;
                 cacheManager = new MemcachedManager(configuration.PoolSet);
             }
             else if (configuration.CacheType == CACHE_TYPE_ASPNET)
             {
                 Enable       = true;
                 cacheManager = new DotNetCacheManager();
             }
             else if (configuration.CacheType == CACHE_TYPE_COUCH)
             {
                 Enable       = true;
                 cacheManager = new CouchCacheManager();
             }
         }
     }
     catch (Exception e)
     {
         Enable = false;
         logger.Error(e);
         configuration            = new RestCacheConfiguration();
         configuration.CacheItems = new List <CacheItem>();
     }
 }