protected virtual async Task <PropertySettingCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey) { var cacheKey = CalculateCacheKey(CurrentTenant.Id, name, providerName, providerKey); var cacheItem = await Cache.GetAsync(cacheKey, considerUow : true); if (cacheItem != null) { return(cacheItem); } cacheItem = new PropertySettingCacheItem(null, true, false, null); await SetCacheItemsAsync(providerName, providerKey, name, cacheItem); return(cacheItem); }
private async Task SetCacheItemsAsync( string providerName, string providerKey, string currentName, PropertySettingCacheItem currentCacheItem) { var settingsDictionary = (await SettingRepository.GetListAsync(providerName, providerKey)); var cacheItems = new List <KeyValuePair <string, PropertySettingCacheItem> >(); foreach (var dic in settingsDictionary) { cacheItems.Add( new KeyValuePair <string, PropertySettingCacheItem>( CalculateCacheKey(dic.TenantId, dic.Name, dic.ProviderName, dic.ProviderKey), new PropertySettingCacheItem(dic.Value, dic.Visible, dic.RequiredRegEx, dic.RegExRule) ) ); } await Cache.SetManyAsync(cacheItems, considerUow : true); }
protected virtual string GetSettingNameFormCacheKeyOrNull(string key) { //TODO: throw ex when name is null? return(PropertySettingCacheItem.GetSettingNameFormCacheKeyOrNull(key)); }
protected virtual string CalculateCacheKey(Guid?tenantId, string name, string providerName, string providerKey) { return(PropertySettingCacheItem.CalculateCacheKey(tenantId, name, providerName, providerKey)); }