[opt](memory) All LRU Cache inherit from LRUCachePolicy (#28940)
After all LRU Cache inherits from LRUCachePolicy, this will allow prune stale entry, eviction when memory exceeds limit, and define common properties. LRUCache constructor change to private, only allow LRUCachePolicy to construct it. Impl DummyLRUCache, when LRU Cache capacity is 0, will no longer be meaningless insert and evict.
This commit is contained in:
@ -27,6 +27,9 @@ int64_t CacheManager::for_each_cache_prune_stale_wrap(
|
||||
int64_t freed_size = 0;
|
||||
std::lock_guard<std::mutex> l(_caches_lock);
|
||||
for (auto cache_policy : _caches) {
|
||||
if (!cache_policy->enable_prune()) {
|
||||
continue;
|
||||
}
|
||||
func(cache_policy);
|
||||
freed_size += cache_policy->profile()->get_counter("FreedMemory")->value();
|
||||
if (cache_policy->profile()->get_counter("FreedMemory")->value() != 0 && profile) {
|
||||
|
||||
Reference in New Issue
Block a user