Add KeyValueSyncInterface::for_each.
This commit is contained in:
parent
cd3cc873f0
commit
58ea5e22bc
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue