コード例 #1
0
        public async Task <ExpandoObject> GetMasterAsync(ICurrentRequest currentRequest)
        {
            var cacheItemValue =
                await _dataFactory.CacheRepository.GetValueAsync <ExpandoObject>(currentRequest, CacheRepository.CacheMasterKey);

            if (cacheItemValue == null)
            {
                var master = await _cacheProvider.GetMasterAsync(currentRequest);

                var cacheItem = new CacheItem();
                cacheItem.Value      = JsonConvert.SerializeObject(master);
                cacheItem.Key        = JsonConvert.SerializeObject(currentRequest);
                cacheItem.Type       = CacheRepository.CacheMasterKey;
                cacheItem.SiteId     = currentRequest.SiteId;
                cacheItem.CreateDate = DateTime.Now;
                await _dataFactory.CacheRepository.SaveAsync(cacheItem);

                return(master);
            }
            // cacheItem.MasterJson
            //Json. ExpandoObject
            return(cacheItemValue);
        }