diff options
| -rw-r--r-- | tddb/td/db/BinlogKeyValue.h | 7 | ||||
| -rw-r--r-- | tddb/td/db/KeyValueSyncInterface.h | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tddb/td/db/BinlogKeyValue.h b/tddb/td/db/BinlogKeyValue.h index 034db47b8..735e120d0 100644 --- a/tddb/td/db/BinlogKeyValue.h +++ b/tddb/td/db/BinlogKeyValue.h @@ -220,6 +220,13 @@ class BinlogKeyValue final : public KeyValueSyncInterface { binlog_->lazy_sync(std::move(promise)); } + void for_each(std::function<void(Slice, Slice)> func) final { + auto lock = rw_mutex_.lock_write().move_as_ok(); + for (const auto &kv : map_) { + func(kv.first, kv.second.first); + } + } + std::unordered_map<string, string, Hash<string>> prefix_get(Slice prefix) final { auto lock = rw_mutex_.lock_write().move_as_ok(); std::unordered_map<string, string, Hash<string>> res; diff --git a/tddb/td/db/KeyValueSyncInterface.h b/tddb/td/db/KeyValueSyncInterface.h index d9e53cbf8..d4e43ffef 100644 --- a/tddb/td/db/KeyValueSyncInterface.h +++ b/tddb/td/db/KeyValueSyncInterface.h @@ -12,6 +12,7 @@ #include "td/utils/Promise.h" #include "td/utils/Slice.h" +#include <functional> #include <unordered_map> namespace td { @@ -35,6 +36,8 @@ class KeyValueSyncInterface { virtual string get(const string &key) = 0; + virtual void for_each(std::function<void(Slice, Slice)> func) = 0; + virtual std::unordered_map<string, string, Hash<string>> prefix_get(Slice prefix) = 0; virtual FlatHashMap<string, string> get_all() = 0; |
