Kagome
Polkadot Runtime Engine in C++17
kagome::storage::InMemoryStorage Class Reference

#include <in_memory_storage.hpp>

Inheritance diagram for kagome::storage::InMemoryStorage:
Collaboration diagram for kagome::storage::InMemoryStorage:

Public Member Functions

 ~InMemoryStorage () override=default
 
outcome::result< common::Bufferload (const common::BufferView &key) const override
 
outcome::result< std::optional< common::Buffer > > tryLoad (const common::BufferView &key) const override
 
outcome::result< void > put (const common::BufferView &key, const common::Buffer &value) override
 
outcome::result< void > put (const common::BufferView &key, common::Buffer &&value) override
 
outcome::result< bool > contains (const common::BufferView &key) const override
 
bool empty () const override
 Returns true if the storage is empty. More...
 
outcome::result< void > remove (const common::BufferView &key) override
 
std::unique_ptr< kagome::storage::face::WriteBatch< common::BufferView, common::Buffer > > batch () override
 Creates new Write Batch - an object, which can be used to efficiently write bulk data. More...
 
std::unique_ptr< storage::BufferStorage::Cursorcursor () override
 Returns new key-value iterator. More...
 
size_t size () const override
 
- Public Member Functions inherited from kagome::storage::face::Iterable< K, V, KView >
virtual ~Iterable ()=default
 
- Public Member Functions inherited from kagome::storage::face::ReadableStorage< KView, V >
virtual ~ReadableStorage ()=default
 
virtual outcome::result< V > load (const Key &key) const =0
 Load value by key. More...
 
virtual outcome::result< std::optional< V > > tryLoad (const Key &key) const =0
 Load value by key. More...
 
- Public Member Functions inherited from kagome::storage::face::ReadableBase< KView >
virtual ~ReadableBase ()=default
 
virtual outcome::result< bool > contains (const Key &key) const =0
 Checks if given key-value binding exists in the storage. More...
 
- Public Member Functions inherited from kagome::storage::face::Writeable< KView, V >
virtual ~Writeable ()=default
 
virtual outcome::result< void > put (const KView &key, const V &value)=0
 Store value by key. More...
 
virtual outcome::result< void > put (const KView &key, V &&value)=0
 
virtual outcome::result< void > remove (const KView &key)=0
 Remove value by key. More...
 
- Public Member Functions inherited from kagome::storage::face::BatchWriteable< KView, V >
virtual ~BatchWriteable ()=default
 

Private Attributes

std::map< std::string, common::Bufferstorage
 
size_t size_ = 0
 

Additional Inherited Members

- Public Types inherited from kagome::storage::face::Iterable< K, V, KView >
using Cursor = MapCursor< K, V, KView >
 
- Public Types inherited from kagome::storage::face::ReadableStorage< KView, V >
using Key = KView
 
using Value = V
 
- Public Types inherited from kagome::storage::face::ReadableBase< KView >
using Key = KView
 

Detailed Description

Simple storage that conforms PersistentMap interface Mostly needed to have an in-memory trie in tests to avoid integration with an actual persistent database

Definition at line 22 of file in_memory_storage.hpp.

Constructor & Destructor Documentation

kagome::storage::InMemoryStorage::~InMemoryStorage ( )
overridedefault

Member Function Documentation

std::unique_ptr< kagome::storage::face::WriteBatch< BufferView, Buffer > > kagome::storage::InMemoryStorage::batch ( )
overridevirtual

Creates new Write Batch - an object, which can be used to efficiently write bulk data.

Implements kagome::storage::face::BatchWriteable< KView, V >.

Definition at line 77 of file in_memory_storage.cpp.

outcome::result< bool > kagome::storage::InMemoryStorage::contains ( const common::BufferView key) const
override

Definition at line 59 of file in_memory_storage.cpp.

std::unique_ptr< InMemoryStorage::Cursor > kagome::storage::InMemoryStorage::cursor ( )
overridevirtual

Returns new key-value iterator.

Returns
kv iterator

Implements kagome::storage::face::Iterable< K, V, KView >.

Definition at line 81 of file in_memory_storage.cpp.

bool kagome::storage::InMemoryStorage::empty ( ) const
overridevirtual

Returns true if the storage is empty.

Implements kagome::storage::face::ReadableBase< KView >.

Definition at line 63 of file in_memory_storage.cpp.

outcome::result< common::Buffer > kagome::storage::InMemoryStorage::load ( const common::BufferView key) const
override

Definition at line 15 of file in_memory_storage.cpp.

outcome::result< void > kagome::storage::InMemoryStorage::put ( const common::BufferView key,
const common::Buffer value 
)
override

Definition at line 33 of file in_memory_storage.cpp.

outcome::result< void > kagome::storage::InMemoryStorage::put ( const common::BufferView key,
common::Buffer &&  value 
)
override

Definition at line 46 of file in_memory_storage.cpp.

outcome::result< void > kagome::storage::InMemoryStorage::remove ( const common::BufferView key)
override

Definition at line 67 of file in_memory_storage.cpp.

size_t kagome::storage::InMemoryStorage::size ( ) const
overridevirtual

Reports RAM state size

Returns
size in bytes

Implements kagome::storage::face::GenericStorage< K, V, KView >.

Definition at line 85 of file in_memory_storage.cpp.

outcome::result< std::optional< Buffer > > kagome::storage::InMemoryStorage::tryLoad ( const common::BufferView key) const
override

Definition at line 24 of file in_memory_storage.cpp.

Member Data Documentation

size_t kagome::storage::InMemoryStorage::size_ = 0
private

Definition at line 55 of file in_memory_storage.hpp.

std::map<std::string, common::Buffer> kagome::storage::InMemoryStorage::storage
private

Definition at line 54 of file in_memory_storage.hpp.


The documentation for this class was generated from the following files: