コード例 #1
0
ファイル: HomeBus.cs プロジェクト: TuanCruise/Code
        /// <summary>
        /// Load Tất cả defTask vào cache
        /// </summary>
        /// <returns></returns>
        public async Task <List <DefTasks> > LoadAllDefTasks()
        {
            try
            {
                string key        = ECacheKey.DefTasks.ToString();
                var    cachedData = _distributedCache.GetString(key);
                if (cachedData != null && cachedData != "null")
                {
                    var defTasks = JsonConvert.DeserializeObject <List <DefTasks> >(cachedData);
                    return(defTasks);
                }
                else
                {
                    var defTasks = await _moduleService.GetAllDefTasks();

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