diff --git a/include/ircd/db/cache.h b/include/ircd/db/cache.h index 6c995ecb8..38c9d8831 100644 --- a/include/ircd/db/cache.h +++ b/include/ircd/db/cache.h @@ -66,3 +66,100 @@ namespace ircd::db void clear(rocksdb::Cache &); void clear(rocksdb::Cache *const &); } + +inline void +ircd::db::clear(rocksdb::Cache *const &cache) +{ + if(cache) + return clear(*cache); +} + +inline bool +ircd::db::remove(rocksdb::Cache *const &cache, + const string_view &key) +{ + return cache? + remove(*cache, key): + false; +} + +inline bool +ircd::db::insert(rocksdb::Cache *const &cache, + const string_view &key, + const string_view &value) +{ + return cache? + insert(*cache, key, value): + false; +} + +inline bool +ircd::db::insert(rocksdb::Cache *const &cache, + const string_view &key, + unique_buffer &&value) +{ + return cache? + insert(*cache, key, std::move(value)): + false; +} + +inline void +ircd::db::for_each(const rocksdb::Cache *const &cache, + const cache_closure &closure) +{ + if(cache) + for_each(*cache, closure); +} + +inline bool +ircd::db::exists(const rocksdb::Cache *const &cache, + const string_view &key) +{ + return cache? + exists(*cache, key): + false; +} + +inline size_t +ircd::db::pinned(const rocksdb::Cache *const &cache) +{ + return cache? + pinned(*cache): + 0UL; +} + +inline size_t +ircd::db::usage(const rocksdb::Cache *const &cache) +{ + return cache? + usage(*cache): + 0UL; +} + +inline bool +ircd::db::capacity(rocksdb::Cache *const &cache, + const size_t &cap) +{ + if(!cache) + return false; + + capacity(*cache, cap); + return true; +} + +inline size_t +ircd::db::capacity(const rocksdb::Cache *const &cache) +{ + return cache? + capacity(*cache): + 0UL; +} + +inline uint64_t +ircd::db::ticker(const rocksdb::Cache *const &cache, + const uint32_t &ticker_id) +{ + return cache? + ticker(*cache, ticker_id): + 0UL; +} diff --git a/ircd/db.cc b/ircd/db.cc index a19fa20fc..9f84fa5bd 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -7042,26 +7042,12 @@ const // cache.h // -void -ircd::db::clear(rocksdb::Cache *const &cache) -{ - if(cache) - return clear(*cache); -} - void ircd::db::clear(rocksdb::Cache &cache) { cache.EraseUnRefEntries(); } -bool -ircd::db::remove(rocksdb::Cache *const &cache, - const string_view &key) -{ - return cache? remove(*cache, key) : false; -} - bool ircd::db::remove(rocksdb::Cache &cache, const string_view &key) @@ -7070,14 +7056,6 @@ ircd::db::remove(rocksdb::Cache &cache, return true; } -bool -ircd::db::insert(rocksdb::Cache *const &cache, - const string_view &key, - const string_view &value) -{ - return cache? insert(*cache, key, value) : false; -} - bool ircd::db::insert(rocksdb::Cache &cache, const string_view &key, @@ -7091,14 +7069,6 @@ ircd::db::insert(rocksdb::Cache &cache, return insert(cache, key, std::move(buf)); } -bool -ircd::db::insert(rocksdb::Cache *const &cache, - const string_view &key, - unique_buffer &&value) -{ - return cache? insert(*cache, key, std::move(value)) : false; -} - bool ircd::db::insert(rocksdb::Cache &cache, const string_view &key, @@ -7130,14 +7100,6 @@ ircd::db::insert(rocksdb::Cache &cache, return true; } -void -ircd::db::for_each(const rocksdb::Cache *const &cache, - const cache_closure &closure) -{ - if(cache) - for_each(*cache, closure); -} - void ircd::db::for_each(const rocksdb::Cache &cache, const cache_closure &closure) @@ -7170,13 +7132,7 @@ ircd::db::for_each(const rocksdb::Cache &cache, true); } -bool -ircd::db::exists(const rocksdb::Cache *const &cache, - const string_view &key) -{ - return cache? exists(*cache, key) : false; -} - +[[gnu::hot]] bool ircd::db::exists(const rocksdb::Cache &cache_, const string_view &key) @@ -7197,41 +7153,18 @@ ircd::db::exists(const rocksdb::Cache &cache_, return bool(handle); } -size_t -ircd::db::pinned(const rocksdb::Cache *const &cache) -{ - return cache? pinned(*cache) : 0; -} - size_t ircd::db::pinned(const rocksdb::Cache &cache) { return cache.GetPinnedUsage(); } -size_t -ircd::db::usage(const rocksdb::Cache *const &cache) -{ - return cache? usage(*cache) : 0; -} - size_t ircd::db::usage(const rocksdb::Cache &cache) { return cache.GetUsage(); } -bool -ircd::db::capacity(rocksdb::Cache *const &cache, - const size_t &cap) -{ - if(!cache) - return false; - - capacity(*cache, cap); - return true; -} - void ircd::db::capacity(rocksdb::Cache &cache, const size_t &cap) @@ -7239,25 +7172,12 @@ ircd::db::capacity(rocksdb::Cache &cache, cache.SetCapacity(cap); } -size_t -ircd::db::capacity(const rocksdb::Cache *const &cache) -{ - return cache? capacity(*cache): 0; -} - size_t ircd::db::capacity(const rocksdb::Cache &cache) { return cache.GetCapacity(); } -uint64_t -ircd::db::ticker(const rocksdb::Cache *const &cache, - const uint32_t &ticker_id) -{ - return cache? ticker(*cache, ticker_id) : 0UL; -} - const uint64_t & ircd::db::ticker(const rocksdb::Cache &cache, const uint32_t &ticker_id)