コード例 #1
0
        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;
            }
        }
コード例 #2
0
 /// <summary>
 /// Sets the local caching properties.
 /// </summary>
 /// <param name="caching">a <see cref="FeatureStoreCacheConfig"/> object</param>
 /// <returns>the builder</returns>
 public CachingStoreWrapperBuilder WithCaching(FeatureStoreCacheConfig caching)
 {
     _caching = caching;
     return(this);
 }
コード例 #3
0
 /// <summary>
 /// Override this method to create a new instance of the appropriate feature store class.
 /// The properties of every instance should be the same except for the caching configuration.
 /// </summary>
 /// <param name="caching">the caching configuration</param>
 /// <returns>a store instance</returns>
 protected abstract IFeatureStore CreateStoreImpl(FeatureStoreCacheConfig caching);
コード例 #4
0
 override protected IFeatureStore CreateStoreImpl(FeatureStoreCacheConfig caching)
 {
     return(RedisFeatureStoreBuilder.Default().WithCaching(caching).
            CreateFeatureStore());
 }
コード例 #5
0
 /// <summary>
 /// Specifies whether local caching should be enabled and if so, sets the cache properties. Local
 /// caching is enabled by default; see <see cref="FeatureStoreCacheConfig.Enabled"/>. To disable it, pass
 /// <see cref="FeatureStoreCacheConfig.Disabled"/> to this method.
 /// </summary>
 /// <param name="caching">a <see cref="FeatureStoreCacheConfig"/> object specifying caching parameters</param>
 /// <returns>the same builder instance</returns>
 public RedisFeatureStoreBuilder WithCaching(FeatureStoreCacheConfig caching)
 {
     Caching = caching;
     return(this);
 }