TARAXA
taraxa::MapByBlockCache< Key, Value > Class Template Reference

#include <cache.hpp>

Public Types

using GetterFn = std::function< Value(uint64_t, const Key &)>
 
using ValueMap = std::unordered_map< Key, Value >
 
using DataMap = std::map< uint64_t, ValueMap >
 

Public Member Functions

 MapByBlockCache (const MapByBlockCache &)=delete
 
 MapByBlockCache (MapByBlockCache &&)=delete
 
MapByBlockCacheoperator= (const MapByBlockCache &)=delete
 
MapByBlockCacheoperator= (MapByBlockCache &&)=delete
 
 MapByBlockCache (uint64_t blocks_to_save, GetterFn &&getter_fn)
 
void append (uint64_t block_num, const Key &key, const Value &value) const
 
Value get (uint64_t blk_num, const Key &key) const
 
uint64_t lastBlockNum () const
 

Protected Attributes

const uint64_t kBlocksToKeep
 
GetterFn getter_fn_
 
std::shared_mutex mutex_
 
DataMap data_by_block_
 

Member Typedef Documentation

◆ DataMap

template<class Key , class Value >
using taraxa::MapByBlockCache< Key, Value >::DataMap = std::map<uint64_t, ValueMap>

◆ GetterFn

template<class Key , class Value >
using taraxa::MapByBlockCache< Key, Value >::GetterFn = std::function<Value(uint64_t, const Key &)>

◆ ValueMap

template<class Key , class Value >
using taraxa::MapByBlockCache< Key, Value >::ValueMap = std::unordered_map<Key, Value>

Constructor & Destructor Documentation

◆ MapByBlockCache() [1/3]

template<class Key , class Value >
taraxa::MapByBlockCache< Key, Value >::MapByBlockCache ( const MapByBlockCache< Key, Value > &  )
delete

◆ MapByBlockCache() [2/3]

template<class Key , class Value >
taraxa::MapByBlockCache< Key, Value >::MapByBlockCache ( MapByBlockCache< Key, Value > &&  )
delete

◆ MapByBlockCache() [3/3]

template<class Key , class Value >
taraxa::MapByBlockCache< Key, Value >::MapByBlockCache ( uint64_t  blocks_to_save,
GetterFn &&  getter_fn 
)
inline

Member Function Documentation

◆ append()

template<class Key , class Value >
void taraxa::MapByBlockCache< Key, Value >::append ( uint64_t  block_num,
const Key &  key,
const Value &  value 
) const
inline

◆ get()

template<class Key , class Value >
Value taraxa::MapByBlockCache< Key, Value >::get ( uint64_t  blk_num,
const Key &  key 
) const
inline

◆ lastBlockNum()

template<class Key , class Value >
uint64_t taraxa::MapByBlockCache< Key, Value >::lastBlockNum ( ) const
inline

◆ operator=() [1/2]

template<class Key , class Value >
MapByBlockCache& taraxa::MapByBlockCache< Key, Value >::operator= ( const MapByBlockCache< Key, Value > &  )
delete

◆ operator=() [2/2]

template<class Key , class Value >
MapByBlockCache& taraxa::MapByBlockCache< Key, Value >::operator= ( MapByBlockCache< Key, Value > &&  )
delete

Member Data Documentation

◆ data_by_block_

template<class Key , class Value >
DataMap taraxa::MapByBlockCache< Key, Value >::data_by_block_
mutableprotected

◆ getter_fn_

template<class Key , class Value >
GetterFn taraxa::MapByBlockCache< Key, Value >::getter_fn_
protected

◆ kBlocksToKeep

template<class Key , class Value >
const uint64_t taraxa::MapByBlockCache< Key, Value >::kBlocksToKeep
protected

◆ mutex_

template<class Key , class Value >
std::shared_mutex taraxa::MapByBlockCache< Key, Value >::mutex_
mutableprotected

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