Ejemplo n.º 1
0
        protected virtual async Task <SettingCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey)
        {
            var cacheKey  = CalculateCacheKey(name, providerName, providerKey);
            var cacheItem = await Cache.GetAsync(cacheKey);

            if (cacheItem != null)
            {
                return(cacheItem);
            }

            var setting = await SettingRepository.FindAsync(name, providerName, providerKey);

            cacheItem = new SettingCacheItem(setting?.Value);

            await Cache.SetAsync(
                cacheKey,
                cacheItem
                );

            return(cacheItem);
        }
 protected virtual string CalculateCacheKey(string name, string providerName, string providerKey)
 {
     return(SettingCacheItem.CalculateCacheKey(name, providerName, providerKey));
 }