public ContextFeatureStateCache(IContextFeatureStateCacheProvider <TContext> cacheProvider, IContextKeyProvider <TContext> keyProvider) { _cacheProvider = cacheProvider; _keyProvider = keyProvider; _cacheLoaded = new Connectable <IObserver <IContextCodeFeatureStateCacheLoaded> >(); _cacheUpdated = new Connectable <IObserver <IContextCodeFeatureStateCacheUpdated> >(); _cache = Task.Run(async() => await LoadCache()).Result; }
public async Task ReloadCache() { DateTime startTime = DateTime.UtcNow; IContextFeatureStateCacheInstance <TContext> cache = await LoadCache(); DateTime endTime = DateTime.UtcNow; Interlocked.Exchange(ref _cache, cache); var loaded = new ContextCodeFeatureStateCacheLoaded(startTime, endTime - startTime, cache.Count); _cacheLoaded.ForEach(x => x.OnNext(loaded)); }