| 391 | |
| 392 | template<Cache::EvictionPolicy policy> |
| 393 | Cache::Handle* CacheShard<policy>::Lookup(const Slice& key, |
| 394 | uint32_t hash, |
| 395 | bool caching) { |
| 396 | RLHandle* e; |
| 397 | { |
| 398 | std::lock_guard<decltype(mutex_)> l(mutex_); |
| 399 | e = table_.Lookup(key, hash); |
| 400 | if (e != nullptr) { |
| 401 | e->refs.fetch_add(1, std::memory_order_relaxed); |
| 402 | RL_UpdateAfterLookup(e); |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | // Do the metrics outside of the lock. |
| 407 | UpdateMetricsLookup(e != nullptr, caching); |
| 408 | |
| 409 | return reinterpret_cast<Cache::Handle*>(e); |
| 410 | } |
| 411 | |
| 412 | template<Cache::EvictionPolicy policy> |
| 413 | void CacheShard<policy>::Release(Cache::Handle* handle) { |
no outgoing calls