diff --git a/Code/RocksDBCache.h b/Code/RocksDBCache.h index 4bc7b17..4166595 100644 --- a/Code/RocksDBCache.h +++ b/Code/RocksDBCache.h @@ -35,6 +35,12 @@ NS_ASSUME_NONNULL_BEGIN */ + (instancetype)LRUCacheWithCapacity:(size_t)capacity numShardsBits:(int)numShardBits; + +/** + Removes all unreferenced entries from the cache. + */ +- (void)eraseUnreferencedEntries; + @end NS_ASSUME_NONNULL_END diff --git a/Code/RocksDBCache.mm b/Code/RocksDBCache.mm index 570c391..741f3c0 100644 --- a/Code/RocksDBCache.mm +++ b/Code/RocksDBCache.mm @@ -9,6 +9,7 @@ #import "RocksDBCache.h" #import +#import @interface RocksDBCache () { @@ -39,6 +40,15 @@ - (instancetype)initWithNativeCache:(std::shared_ptr)cache return self; } +- (void)eraseUnreferencedEntries +{ + @synchronized(self) { + if (_cache != nullptr) { + _cache->EraseUnRefEntries(); + } + } +} + - (void)dealloc { @synchronized(self) {