0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-02-18 09:40:12 +01:00

ircd::db: Add cache key remover.

This commit is contained in:
Jason Volk 2018-05-14 17:01:33 -07:00
parent 9e0acde5cf
commit 47b28d9295
2 changed files with 19 additions and 0 deletions

View file

@ -37,6 +37,10 @@ namespace ircd::db
bool exists(rocksdb::Cache &, const string_view &key);
bool exists(rocksdb::Cache *const &, const string_view &key);
// Remove key if it exists
void remove(rocksdb::Cache &, const string_view &key);
void remove(rocksdb::Cache *const &, const string_view &key);
// Iterate the cache entries.
using cache_closure = std::function<void (const string_view &, const size_t &)>;
void for_each(rocksdb::Cache &, const cache_closure &);

View file

@ -5118,6 +5118,21 @@ ircd::db::for_each(rocksdb::Cache &cache,
false);
}
void
ircd::db::remove(rocksdb::Cache *const &cache,
const string_view &key)
{
if(cache)
remove(*cache, key);
}
void
ircd::db::remove(rocksdb::Cache &cache,
const string_view &key)
{
cache.Erase(slice(key));
}
bool
ircd::db::exists(rocksdb::Cache *const &cache,
const string_view &key)