Exemplo n.º 1
0
        /// <summary>
        /// Load Tất cả defcode vào cache
        /// </summary>
        /// <returns></returns>
        public async Task <List <CodeInfo> > LoadAllDefCode()
        {
            try
            {
                string key        = ECacheKey.DefCode.ToString();
                var    cachedData = _distributedCache.GetString(key);
                if (cachedData != null && cachedData != "null")
                {
                    var defcodes = JsonConvert.DeserializeObject <List <CodeInfo> >(cachedData);
                    return(defcodes);
                }
                else
                {
                    var defcodes = await _moduleService.GetAllDefCode();

                    RedisUtils.SetCacheData(_distributedCache, _Configuration, defcodes, key);
                    return(defcodes);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }