diff --git a/util/lru_cache.cc b/util/lru_cache.cc index 83094266c..58ec02fb4 100644 --- a/util/lru_cache.cc +++ b/util/lru_cache.cc @@ -259,14 +259,11 @@ Cache::Handle* LRUCacheShard::Lookup(const Slice& key, uint32_t hash) { bool LRUCacheShard::Ref(Cache::Handle* h) { LRUHandle* handle = reinterpret_cast(h); MutexLock l(&mutex_); - if (handle->InCache()) { - if (handle->refs == 1) { - LRU_Remove(handle); - } - handle->refs++; - return true; + if (handle->InCache() && handle->refs == 1) { + LRU_Remove(handle); } - return false; + handle->refs++; + return true; } void LRUCacheShard::SetHighPriorityPoolRatio(double high_pri_pool_ratio) {