]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/shared_cache.hpp: add clear()
authorSamuel Just <sam.just@inktank.com>
Tue, 21 May 2013 19:47:05 +0000 (12:47 -0700)
committerSamuel Just <sam.just@inktank.com>
Tue, 21 May 2013 19:51:20 +0000 (12:51 -0700)
Clear clears a key/value from the cache.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/common/shared_cache.hpp

index 69a4c06dfbf5f4b79ea27cd599136440da463eb4..50da23a4f2fd5253f9178d9a215ba0af3657b05a 100644 (file)
@@ -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<VPtr> to_release;
     {