public async Task <ApplicationConfigurationDto> GetAsync() { var cacheKey = CreateCacheKey(); var httpContext = HttpContextAccessor?.HttpContext; if (httpContext != null && !httpContext.WebSockets.IsWebSocketRequest && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) { return(configuration); } configuration = await Cache.GetOrAddAsync( cacheKey, async() => await ApplicationConfigurationAppService.GetAsync(), () => new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300) //TODO: Should be configurable. } ); if (httpContext != null && !httpContext.WebSockets.IsWebSocketRequest) { httpContext.Items[cacheKey] = configuration; } return(configuration); }
public virtual async Task InitializeAsync() { var configurationDto = await ApplicationConfigurationAppService.GetAsync(); Cache.Set(configurationDto); CurrentTenantAccessor.Current = new BasicTenantInfo( configurationDto.CurrentTenant.Id, configurationDto.CurrentTenant.Name ); }