diff options
Diffstat (limited to 'staging_vespalib')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h index 993163a82cd..d0fb4259b30 100644 --- a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h +++ b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h @@ -120,7 +120,11 @@ public: * Object is then put at head of LRU list. */ insert_result insert(const K & key, const V & value) { - return insert(value_type(key, LV(value))); + insert_result res = insert(value_type(key, LV(value))); + if (res.second) { + onInsert(key); + } + return res; } /** @@ -155,6 +159,12 @@ public: (void) v; return (size() > capacity()); } + virtual void onRemove(const K & key) { + (void) key; + } + virtual void onInsert(const K & key) { + (void) key; + } /** * Method for testing that internal consitency is good. @@ -255,6 +265,7 @@ void lrucache_map<P>::erase(const K & key) { internal_iterator it = HashTable::find(key); if (it != HashTable::end()) { + onRemove(key); LV & v = it->second; if (v._prev != LinkedValueBase::npos) { HashTable::getByInternalIndex(v._prev).second._next = v._next; |