From: Samuel Just Date: Tue, 21 May 2013 19:47:05 +0000 (-0700) Subject: common/shared_cache.hpp: add clear() X-Git-Tag: v0.65~194^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=12eff5d9ff46617f0067a1c57e2b61fc43afb3bb;p=ceph.git common/shared_cache.hpp: add clear() Clear clears a key/value from the cache. Signed-off-by: Samuel Just --- diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index 69a4c06dfbf5..50da23a4f2fd 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -85,6 +85,17 @@ public: assert(weak_refs.empty()); } + void clear(K key) { + VPtr val; // release any ref we have after we drop the lock + { + Mutex::Locker l(lock); + if (weak_refs.count(key)) { + val = weak_refs[key].lock(); + } + lru_remove(key); + } + } + void set_size(size_t new_size) { list to_release; {