| 425 | |
| 426 | template <typename Key, typename Value> |
| 427 | bool WebCache<Key, Value>::remove_if( |
| 428 | const Key& key, const ValuePtr& expected_val) { |
| 429 | std::lock_guard<std::shared_mutex> lock(_cache_mutex); |
| 430 | if (auto search = _lookup.find(key); |
| 431 | (search != _lookup.end() && search->second.value == expected_val)) { |
| 432 | auto [_, hand_moved] = |
| 433 | sieve_remove_unmutexed(_sieve_queue, _sieve_hand, search->second); |
| 434 | _lookup.erase(search); |
| 435 | _sieve_hand = hand_moved; |
| 436 | return true; |
| 437 | } |
| 438 | return false; |
| 439 | } |
| 440 | |
| 441 | template <typename Key, typename Value> |
| 442 | std::optional<typename WebCache<Key, Value>::ValuePtr> |