0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 23:40:57 +01:00

ircd::db: Typedef / minor reorg property related interface.

This commit is contained in:
Jason Volk 2018-04-03 10:58:16 -07:00
parent 199ccad3e1
commit 0bf6742ac9
3 changed files with 17 additions and 9 deletions

View file

@ -23,10 +23,12 @@ namespace ircd::db
size_t bytes(const column &);
// Get property data of a db column. R can optionally be uint64_t for some
// values. Refer to RocksDB documentation for more info.
template<class R = std::string> R property(const column &, const string_view &name);
template<> std::string property(const column &, const string_view &name);
template<> uint64_t property(const column &, const string_view &name);
// values; we typedef that as prop_int for templating purposes. R can also
// be an std::string which we typedef as prop_str. Refer to RocksDB
// documentation for more info.
template<class R = prop_str> R property(const column &, const string_view &name);
template<> prop_str property(const column &, const string_view &name);
template<> prop_int property(const column &, const string_view &name);
// [GET] Tests if key exists
bool has(column &, const string_view &key, const gopts & = {});

View file

@ -15,11 +15,17 @@ namespace ircd::db
{
struct database;
template<class R = uint64_t> R property(const database &, const string_view &name);
template<> uint64_t property(const database &, const string_view &name);
// General information
const std::string &name(const database &);
uint64_t sequence(const database &); // Latest sequence number
// Property information interface
using prop_int = uint64_t;
using prop_str = std::string;
template<class R = prop_int> R property(const database &, const string_view &name);
template<> prop_int property(const database &, const string_view &name);
// Control panel
void checkpoint(database &, const string_view &dir);
void flush(database &, const bool &blocking = true);
void sync(database &);

View file

@ -172,7 +172,7 @@ ircd::db::sequence(const database &cd)
}
template<>
uint64_t
ircd::db::prop_int
ircd::db::property(const database &cd,
const string_view &name)
{
@ -3588,7 +3588,7 @@ ircd::db::read(column &column,
}
template<>
std::string
ircd::db::prop_str
ircd::db::property(const column &column,
const string_view &name)
{
@ -3600,7 +3600,7 @@ ircd::db::property(const column &column,
}
template<>
uint64_t
ircd::db::prop_int
ircd::db::property(const column &column,
const string_view &name)
{