Skip to content

Commit

Permalink
Add eraseUnreferencedEntries in RocksDBCache
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpablo committed Jan 24, 2025
1 parent 386b0b0 commit d39bbd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Code/RocksDBCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions Code/RocksDBCache.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "RocksDBCache.h"

#import <rocksdb/cache.h>
#import <rocksdb/advanced_cache.h>

@interface RocksDBCache ()
{
Expand Down Expand Up @@ -39,6 +40,15 @@ - (instancetype)initWithNativeCache:(std::shared_ptr<rocksdb::Cache>)cache
return self;
}

- (void)eraseUnreferencedEntries
{
@synchronized(self) {
if (_cache != nullptr) {
_cache->EraseUnRefEntries();
}
}
}

- (void)dealloc
{
@synchronized(self) {
Expand Down

0 comments on commit d39bbd8

Please sign in to comment.