internal CachingStoreWrapper(IFeatureStoreCore core, FeatureStoreCacheConfig caching) { this._core = core; this._caching = caching; if (caching.IsEnabled) { var itemCacheBuilder = Caches.KeyValue <CacheKey, IVersionedData>() .WithLoader(GetInternalForCache) .WithMaximumEntries(caching.MaximumEntries); var allCacheBuilder = Caches.KeyValue <IVersionedDataKind, ImmutableDictionary <string, IVersionedData> >() .WithLoader(GetAllForCache); var initCacheBuilder = Caches.SingleValue <bool>() .WithLoader(_core.InitializedInternal); if (!caching.IsInfiniteTtl) { itemCacheBuilder.WithExpiration(caching.Ttl); allCacheBuilder.WithExpiration(caching.Ttl); initCacheBuilder.WithExpiration(caching.Ttl); } _itemCache = itemCacheBuilder.Build(); _allCache = allCacheBuilder.Build(); _initCache = initCacheBuilder.Build(); } else { _itemCache = null; _allCache = null; _initCache = null; } }
/// <summary> /// Creates a new builder using a synchronous data store implementation. /// </summary> /// <param name="core">the <see cref="IFeatureStoreCore"/> implementation</param> /// <returns>a builder</returns> public static CachingStoreWrapperBuilder Builder(IFeatureStoreCore core) { return(new CachingStoreWrapperBuilder(core)); }
internal CachingStoreWrapperBuilder(IFeatureStoreCore core) { _core = core; }