| 418 | |
| 419 | template<Cache::EvictionPolicy policy> |
| 420 | void RLCacheShard<policy>::Erase(const Slice& key, uint32_t hash) { |
| 421 | DCHECK(initialized_); |
| 422 | RLHandle* e; |
| 423 | bool last_reference = false; |
| 424 | { |
| 425 | std::lock_guard<decltype(mutex_)> l(mutex_); |
| 426 | e = static_cast<RLHandle*>(table_.Remove(key, hash)); |
| 427 | if (e != nullptr) { |
| 428 | RL_Remove(e); |
| 429 | last_reference = Unref(e); |
| 430 | } |
| 431 | } |
| 432 | // mutex not held here |
| 433 | // last_reference will only be true if e != NULL |
| 434 | if (last_reference) { |
| 435 | FreeEntry(e); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | template<Cache::EvictionPolicy policy> |
| 440 | size_t RLCacheShard<policy>::Invalidate(const Cache::InvalidationControl& ctl) { |