ApplyToAllCacheEntries

Summary: Added a method that executes a callback on every cache entry.

Test Plan: added a unit test

Reviewers: haobo

Reviewed By: haobo

CC: leveldb, dhruba

Differential Revision: https://reviews.facebook.net/D18441
This commit is contained in:
Igor Canadi
2014-05-02 16:24:04 -04:00
parent 31d38a6732
commit 4ecfbcf865
3 changed files with 52 additions and 0 deletions

View File

@@ -116,6 +116,12 @@ class Cache {
// default implementation is noop
};
// Apply callback to all entries in the cache
// If thread_safe is true, it will also lock the accesses. Otherwise, it will
// access the cache without the lock held
virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
bool thread_safe) = 0;
private:
void LRU_Remove(Handle* e);
void LRU_Append(Handle* e);