Newer
Older
#ifndef __VEREIGN_KVSTORE_STORAGE_HH
#define __VEREIGN_KVSTORE_STORAGE_HH
#include <vereign/bytes/buffer.hh>
namespace vereign::kvstore {
constexpr const auto VereignKeyName = std::string_view{"vereign_key"};
/**
* Locks the storage.
*
* The lock must be recursive, meaning that may be called multiple times.
* Storage::Unlock must be called the same number of times the Storage::Lock was called.
*
* Use kvstore::Lock for lock guard and lock with retrials.
*
* @throws LockError when the lock is held by another process.
*/
/**
* Locks the storage.
*
* The lock must be recursive, meaning that may be called multiple times.
* Storage::Unlock must be called the same number of times the Storage::Lock was called.
*
* Use kvstore::Lock for lock guard and lock with retrials.
*/
virtual void Unlock() = 0;
/**
* Store bytes value into the storage.
*
* @param key The key under which the value will be stored.
* @param value The bytes that will be stored.
*/
virtual void PutBytes(const std::string& key, bytes::View value) = 0;
/**
* Retrieve bytes value from the storage.
*
* @param key The key of the value that will be retrieved.
* @param value Buffer where the value will be returned.
*
* @throws ValueNotFoundError when the key does not exist.
*/
virtual void GetBytes(const std::string& key, bytes::Buffer& value) = 0;
/**
* Store int64_t value into the storage.
*
* @param key The key under which the value will be stored.
* @param value The value that will be stored.
*/
virtual void PutInt64(const std::string& key, int64_t value) = 0;
/**
* Retrieve int64_t value from the storage.
*
* @param key The key of the value that will be retrieved.
* @param value Buffer where the value will be returned.
*
* @throws ValueNotFoundError when the key does not exist.
*/
virtual auto GetInt64(const std::string& key) -> int64_t = 0;
virtual ~Storage() = default;
};
} // namespace vereign::kvstore
#endif // __VEREIGN_KVSTORE_STORAGE_HH