From 7efcde12aae4cd6dc0e5ca3e8c044ef4e716e158 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Wed, 2 Sep 2015 18:43:23 +0200 Subject: [PATCH] row_cache: Introduce row_cache::touch() Useful in tests for ensuring that certain entries survive eviction. --- row_cache.cc | 7 +++++++ row_cache.hh | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/row_cache.cc b/row_cache.cc index 09295bcacf..7505e5c152 100644 --- a/row_cache.cc +++ b/row_cache.cc @@ -196,6 +196,13 @@ future<> row_cache::update(memtable& m, partition_presence_checker presence_chec }); } +void row_cache::touch(const dht::decorated_key& dk) { + auto i = _partitions.find(dk, cache_entry::compare(_schema)); + if (i != _partitions.end()) { + _tracker.touch(*i); + } +} + row_cache::row_cache(schema_ptr s, mutation_source fallback_factory, cache_tracker& tracker) : _tracker(tracker) , _schema(std::move(s)) diff --git a/row_cache.hh b/row_cache.hh index 7ae7d1b5fe..ad79964bc7 100644 --- a/row_cache.hh +++ b/row_cache.hh @@ -150,6 +150,10 @@ public: // The memtable can be queried during the process, but must not be written. // After the update is complete, memtable is empty. future<> update(memtable&, partition_presence_checker underlying_negative); + + // Moves given partition to the front of LRU if present in cache. + void touch(const dht::decorated_key&); + auto num_entries() const { return _partitions.size(); }