示例#1
0
        public static List <MiscEntity> GetMisc(MiscEnum misc)
        {
            var    memoryCache = MemoryCache.Default;
            string key         = string.Format("Get_{0}", misc.ToString());

            if (!memoryCache.Contains(key))
            {
                var result = JsonHelper.FromJson <List <MiscEntity> >(JanusClientHelper.GetMisc(misc));
                memoryCache.Add(key, result, new CacheItemPolicy()
                {
                    Priority = CacheItemPriority.NotRemovable
                });
            }
            return(memoryCache.Get(key, null) as List <MiscEntity>);
        }
示例#2
0
        public static List <MiscEntity> GetAllAreas()
        {
            var    memoryCache = MemoryCache.Default;
            string key         = "Get_AllArea";

            if (!memoryCache.Contains(key))
            {
                var province = JsonHelper.FromJson <List <MiscEntity> >(JanusClientHelper.GetMisc(MiscEnum.china_province));
                var city     = JsonHelper.FromJson <List <MiscEntity> >(JanusClientHelper.GetMisc(MiscEnum.china_city));
                var result   = new List <MiscEntity>();
                result.AddRange(province);
                result.AddRange(city);
                memoryCache.Add(key, result, new CacheItemPolicy()
                {
                    Priority = CacheItemPriority.NotRemovable
                });
            }
            return(memoryCache.Get(key, null) as List <MiscEntity>);
        }