diff --git a/include/rocksdb/cache.h b/include/rocksdb/cache.h index 3e0e5c1cd8..7d58e1546a 100644 --- a/include/rocksdb/cache.h +++ b/include/rocksdb/cache.h @@ -104,6 +104,15 @@ class Cache { // returns the maximum configured capacity of the cache virtual size_t GetCapacity() = 0; + // Call this on shutdown if you want to speed it up. Cache will disown + // any underlying data and will not free it on delete. This call will leak + // memory - call this only if you're shutting down the process. + // Any attempts of using cache after this call will fail terribly. + // Always delete the DB object before calling this method! + virtual void DisownData() { + // default implementation is noop + }; + private: void LRU_Remove(Handle* e); void LRU_Append(Handle* e); diff --git a/util/cache.cc b/util/cache.cc index 8fa03626b1..4707eac94a 100644 --- a/util/cache.cc +++ b/util/cache.cc @@ -409,6 +409,9 @@ class ShardedLRUCache : public Cache { virtual size_t GetCapacity() { return capacity_; } + virtual void DisownData() { + shard_ = nullptr; + } }; } // end anonymous namespace