diff --git a/src/StorageCache.cpp b/src/StorageCache.cpp index 64ae0051e..7f86b595e 100644 --- a/src/StorageCache.cpp +++ b/src/StorageCache.cpp @@ -18,10 +18,11 @@ dictType dbStorageCacheType = { NULL /* val destructor */ }; -StorageCache::StorageCache(IStorage *storage) +StorageCache::StorageCache(IStorage *storage, bool fCache) : m_spstorage(storage) { - m_pdict = dictCreate(&dbStorageCacheType, nullptr); + if (fCache) + m_pdict = dictCreate(&dbStorageCacheType, nullptr); } void StorageCache::clear() @@ -94,7 +95,7 @@ const StorageCache *StorageCache::clone() { std::unique_lock ul(m_lock); // Clones never clone the cache - StorageCache *cacheNew = new StorageCache(const_cast(m_spstorage->clone())); + StorageCache *cacheNew = new StorageCache(const_cast(m_spstorage->clone()), false /*fCache*/); return cacheNew; } diff --git a/src/StorageCache.h b/src/StorageCache.h index 33492cab1..c2170b7d0 100644 --- a/src/StorageCache.h +++ b/src/StorageCache.h @@ -8,7 +8,7 @@ class StorageCache int m_collisionCount = 0; mutable fastlock m_lock {"StorageCache"}; - StorageCache(IStorage *storage); + StorageCache(IStorage *storage, bool fNoCache); void cacheKey(sds key); void cacheKey(const char *rgchKey, size_t cchKey); @@ -29,12 +29,7 @@ class StorageCache public: static StorageCache *create(IStorageFactory *pfactory, int db, IStorageFactory::key_load_iterator fn, void *privdata) { - StorageCache *cache = new StorageCache(nullptr); - if (!pfactory->FSlow()) - { - dictRelease(cache->m_pdict); - cache->m_pdict = nullptr; - } + StorageCache *cache = new StorageCache(nullptr, pfactory->FSlow() /*fCache*/); load_iter_data data = {cache, fn, privdata}; cache->m_spstorage = std::shared_ptr(pfactory->create(db, key_load_itr, (void*)&data)); return cache;