blob: 55472a8e46824dec4cc3d833c06a0d27afb4abbb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#pragma once
#include "Api.h"
#include "IStorageBackend.h"
#include <cstdint>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
/**
* @file InMemoryBackend.h
* @brief In-process KV storage backend backed by an unordered_map.
*
* Intended for unit tests where SQLite is not appropriate. Data does not
* survive process exit and is not thread-safe.
*
* Relation membership is tracked by the Merkle class, not this backend.
*/
namespace nt
{
class NT_API InMemoryBackend : public IStorageBackend
{
public:
std::string Put(std::vector<uint8_t> value) override;
std::optional<std::vector<uint8_t>> Get(const std::string& hash) override;
private:
std::unordered_map<std::string, std::vector<uint8_t>> kv_;
};
}
|