2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/db/SqliteKeyValueSafe.h"
|
|
|
|
|
2021-12-16 14:16:34 +01:00
|
|
|
#include "td/utils/common.h"
|
2022-02-07 22:04:34 +01:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
2022-06-27 12:30:18 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2021-12-16 14:16:34 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class SqliteKeyValueAsyncInterface {
|
|
|
|
public:
|
|
|
|
virtual ~SqliteKeyValueAsyncInterface() = default;
|
|
|
|
|
2021-12-12 20:34:19 +01:00
|
|
|
virtual void set(string key, string value, Promise<Unit> promise) = 0;
|
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
virtual void set_all(FlatHashMap<string, string> key_values, Promise<Unit> promise) = 0;
|
2021-12-12 20:34:19 +01:00
|
|
|
|
|
|
|
virtual void erase(string key, Promise<Unit> promise) = 0;
|
|
|
|
|
|
|
|
virtual void erase_by_prefix(string key_prefix, Promise<Unit> promise) = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
virtual void get(string key, Promise<string> promise) = 0;
|
2021-12-12 20:34:19 +01:00
|
|
|
|
|
|
|
virtual void close(Promise<Unit> promise) = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
2018-09-27 03:19:03 +02:00
|
|
|
unique_ptr<SqliteKeyValueAsyncInterface> create_sqlite_key_value_async(std::shared_ptr<SqliteKeyValueSafe> kv,
|
|
|
|
int32 scheduler_id = 1);
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|