row_cache: Introduce row_cache::touch()

Useful in tests for ensuring that certain entries survive eviction.
This commit is contained in:
Tomasz Grabiec
2015-09-02 18:43:23 +02:00
parent 24a5221280
commit 7efcde12aa
2 changed files with 11 additions and 0 deletions

View File

@@ -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))

View File

@@ -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();
}