internal PersistentStoreWrapper(
     IPersistentDataStoreAsync coreAsync,
     DataStoreCacheConfig caching,
     IDataStoreUpdates dataStoreUpdates,
     TaskExecutor taskExecutor,
     Logger log
     ) :
     this(new PersistentStoreAsyncAdapter(coreAsync), caching, dataStoreUpdates, taskExecutor, log)
 {
 }
        internal PersistentStoreWrapper(
            IPersistentDataStore core,
            DataStoreCacheConfig caching,
            IDataStoreUpdates dataStoreUpdates,
            TaskExecutor taskExecutor,
            Logger log
            )
        {
            this._core             = core;
            this._caching          = caching;
            this._dataStoreUpdates = dataStoreUpdates;
            this._log = log;

            _cacheIndefinitely = caching.IsEnabled && caching.IsInfiniteTtl;
            if (caching.IsEnabled)
            {
                var itemCacheBuilder = Caches.KeyValue <CacheKey, ItemDescriptor?>()
                                       .WithLoader(GetInternalForCache)
                                       .WithMaximumEntries(caching.MaximumEntries);
                var allCacheBuilder = Caches.KeyValue <DataKind, ImmutableDictionary <string, ItemDescriptor> >()
                                      .WithLoader(GetAllAndDeserialize);
                var initCacheBuilder = Caches.SingleValue <bool>()
                                       .WithLoader(_core.Initialized);
                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;
            }

            _statusManager = new PersistentDataStoreStatusManager(
                !_cacheIndefinitely,
                true,
                this.PollAvailabilityAfterOutage,
                dataStoreUpdates.UpdateStatus,
                taskExecutor,
                log
                );
        }