コード例 #1
0
        public static Dictionary <string, int> GetAllUpdateSetConfig()
        {
            string key = "HHInfr_CfgService_GetAllUpdateSetConfig";

            try
            {
                MemoryCache localCache = MemoryCache.Default;
                if (localCache[key] == null)
                {
                    Dictionary <string, int>    dic       = new Dictionary <string, int>();
                    MemcachedUpdateSetConfigDAL configDAL = new MemcachedUpdateSetConfigDAL();
                    var allList = configDAL.GetAll();
                    foreach (var item in allList)
                    {
                        dic.Add(item.CacheKeyPrefix, item.UpdateHourSpan);
                    }
                    localCache.Add(key, dic, new DateTimeOffset(DateTime.Now.AddMinutes(KeyMinuteManager.DefaultMinute)));
                    return(dic);
                }
                return(localCache[key] as Dictionary <string, int>);
            }
            catch (Exception ex)
            {
                Logging.HHLogHelperV2.ERRORGlobalException(ex);
                return(new Dictionary <string, int>());
            }
        }
コード例 #2
0
ファイル: CfgService.cs プロジェクト: deboe2015/Ctrip.SOA
 public static Dictionary<string, int> GetAllUpdateSetConfig()
 {
     string key = "HHInfr_CfgService_GetAllUpdateSetConfig";
     try
     {
         MemoryCache localCache = MemoryCache.Default;
         if (localCache[key] == null)
         {
             Dictionary<string, int> dic = new Dictionary<string, int>();
             MemcachedUpdateSetConfigDAL configDAL = new MemcachedUpdateSetConfigDAL();
             var allList = configDAL.GetAll();
             foreach (var item in allList)
             {
                 dic.Add(item.CacheKeyPrefix, item.UpdateHourSpan);
             }
             localCache.Add(key, dic, new DateTimeOffset(DateTime.Now.AddMinutes(KeyMinuteManager.DefaultMinute)));
             return dic;
         }
         return localCache[key] as Dictionary<string, int>;
     }
     catch (Exception ex)
     {
         Logging.HHLogHelperV2.ERRORGlobalException(ex);
         return new Dictionary<string, int>();
     }
 }
コード例 #3
0
        public static void InitCfgData(string key, string jsonCallEnity)
        {
            try
            {
                var    index          = key.IndexOf(CacheManager.MAIN_KEY_SPLIT_CHAR);
                string cacheKeyPrefix = index >= 0 ? key.Substring(0, index) : key;
                MemcachedUpdateSetConfigDAL    configDAL    = new MemcachedUpdateSetConfigDAL();
                MemcachedUpdateSetConfigEntity configEngity = configDAL.Select(string.Format("CacheKeyPrefix='{0}'", cacheKeyPrefix));
                if (configEngity == null)
                {
                    configEngity = new MemcachedUpdateSetConfigEntity();
                    configEngity.CacheKeyPrefix      = cacheKeyPrefix;
                    configEngity.DataChange_LastTime = DateTime.Now;
                    configEngity.FreMin         = 0;//数据库默认
                    configEngity.IsJobActByMin  = 0;
                    configEngity.UpdateHourSpan = KeyMinuteManager.DefaultMinute;
                    configDAL.Insert(configEngity);
                }

                MemcachedUpdateRuleDAL    ruleDAL    = new MemcachedUpdateRuleDAL();
                MemcachedUpdateRuleEntity ruleEntity = ruleDAL.Select(string.Format("CacheKey='{0}'", key));
                if (ruleEntity == null)
                {
                    ruleEntity                     = new MemcachedUpdateRuleEntity();
                    ruleEntity.CacheKey            = key;
                    ruleEntity.CacheKeyPrefix      = cacheKeyPrefix;
                    ruleEntity.ConditionEntityJson = jsonCallEnity;
                    ruleEntity.DataChange_LastTime = DateTime.Now;
                    ruleEntity.IsJobActByMin       = configEngity.IsJobActByMin;
                    ruleEntity.LastUpdateTime      = DateTime.Now;
                    ruleEntity.UpdateHourSpan      = configEngity.UpdateHourSpan;
                    ruleDAL.Insert(ruleEntity);
                }

                MemcachedGetFrequencyDAL    freqDAL    = new MemcachedGetFrequencyDAL();
                MemcachedGetFrequencyEntity freqEntity = freqDAL.Select(string.Format("CacheKey='{0}'", key));
                if (freqEntity == null)
                {
                    freqEntity                     = new MemcachedGetFrequencyEntity();
                    freqEntity.CacheKey            = key;
                    freqEntity.CacheKeyPrefix      = cacheKeyPrefix;
                    freqEntity.DataChange_LastTime = DateTime.Now;
                    freqEntity.FreMin              = configEngity.FreMin;
                    freqEntity.FreCount            = 1;
                    freqEntity.LastGetDateTime     = DateTime.Now;
                    freqDAL.Insert(freqEntity);
                }
            }
            catch (Exception ex)
            {
                Logging.HHLogHelperV2.ERRORGlobalException(ex);
            }
        }
コード例 #4
0
ファイル: CfgService.cs プロジェクト: deboe2015/Ctrip.SOA
        public static void InitCfgData(string key, string jsonCallEnity)
        {
            try
            {
                var index=key.IndexOf(CacheManager.MAIN_KEY_SPLIT_CHAR);
                string cacheKeyPrefix = index >= 0 ? key.Substring(0, index) : key;
                MemcachedUpdateSetConfigDAL configDAL = new MemcachedUpdateSetConfigDAL();
                MemcachedUpdateSetConfigEntity configEngity = configDAL.Select(string.Format("CacheKeyPrefix='{0}'", cacheKeyPrefix));
                if (configEngity == null)
                {
                    configEngity = new MemcachedUpdateSetConfigEntity();
                    configEngity.CacheKeyPrefix = cacheKeyPrefix;
                    configEngity.DataChange_LastTime = DateTime.Now;
                    configEngity.FreMin = 0;//数据库默认
                    configEngity.IsJobActByMin = 0;
                    configEngity.UpdateHourSpan = KeyMinuteManager.DefaultMinute;
                    configDAL.Insert(configEngity);
                }

                MemcachedUpdateRuleDAL ruleDAL = new MemcachedUpdateRuleDAL();
                MemcachedUpdateRuleEntity ruleEntity = ruleDAL.Select(string.Format("CacheKey='{0}'", key));
                if (ruleEntity == null)
                {
                    ruleEntity = new MemcachedUpdateRuleEntity();
                    ruleEntity.CacheKey = key;
                    ruleEntity.CacheKeyPrefix = cacheKeyPrefix;
                    ruleEntity.ConditionEntityJson = jsonCallEnity;
                    ruleEntity.DataChange_LastTime = DateTime.Now;
                    ruleEntity.IsJobActByMin = configEngity.IsJobActByMin;
                    ruleEntity.LastUpdateTime = DateTime.Now;
                    ruleEntity.UpdateHourSpan = configEngity.UpdateHourSpan;
                    ruleDAL.Insert(ruleEntity);
                }

                MemcachedGetFrequencyDAL freqDAL = new MemcachedGetFrequencyDAL();
                MemcachedGetFrequencyEntity freqEntity = freqDAL.Select(string.Format("CacheKey='{0}'", key));
                if (freqEntity == null)
                {
                    freqEntity = new MemcachedGetFrequencyEntity();
                    freqEntity.CacheKey = key;
                    freqEntity.CacheKeyPrefix = cacheKeyPrefix;
                    freqEntity.DataChange_LastTime = DateTime.Now;
                    freqEntity.FreMin = configEngity.FreMin;
                    freqEntity.FreCount = 1;
                    freqEntity.LastGetDateTime = DateTime.Now;
                    freqDAL.Insert(freqEntity);
                }
            }
            catch(Exception ex)
            {
                Logging.HHLogHelperV2.ERRORGlobalException(ex);
            }
        }