public async Task Cache_Should_Invalidator_WhenSettingChanged_Between_Tenant_And_Host() { var tenantId = Guid.NewGuid(); using (_currentTenant.Change(tenantId)) { // GetOrNullAsync will cache language. await _settingManagementStore .GetOrNullAsync("MySetting2", GlobalSettingValueProvider.ProviderName, null) ; } using (_currentTenant.Change(null)) { // SetAsync will make cache invalid. await _settingManagementStore .SetAsync("MySetting2", "MySetting2Value", GlobalSettingValueProvider.ProviderName, null); } using (_currentTenant.Change(tenantId)) { // Assert (await _cache.GetAsync( SettingCacheItem.CalculateCacheKey("MySetting2", GlobalSettingValueProvider.ProviderName, null)) ).ShouldBeNull(); } }
public void GetSettingNameFormCacheKeyOrNull() { var key = SettingCacheItem.CalculateCacheKey("aaa", "bbb", "ccc"); SettingCacheItem.GetSettingNameFormCacheKeyOrNull(key).ShouldBe("aaa"); SettingCacheItem.GetSettingNameFormCacheKeyOrNull("aaabbbccc").ShouldBeNull(); }
public async Task GetOrNullAsync_Should_Cached() { // Act (await _cache.GetAsync(SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()))).ShouldBeNull(); await _settingManagementStore.GetOrNullAsync("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()); (await _cache.GetAsync(SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()))).ShouldNotBeNull(); }
public async Task Cache_Should_Invalidator_WhenSettingChanged() { // Arrange // GetOrNullAsync will cache language. await _settingManagementStore.GetOrNullAsync("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()); // Act var lang = await _settingRepository.FindAsync("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()); await _settingRepository.DeleteAsync(lang); // Assert (await _cache.GetAsync( SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()))).ShouldBeNull(); }
protected virtual string CalculateCacheKey(string name, string providerName, string providerKey) { return(SettingCacheItem.CalculateCacheKey(name, providerName, providerKey)); }