TARAXA
taraxa::ValueByBlockCache< Value > Class Template Reference

#include <cache.hpp>

Public Types

using GetterFn = std::function< Value(uint64_t)>
 
using DataMap = std::map< uint64_t, Value >
 

Public Member Functions

 ValueByBlockCache (const ValueByBlockCache &)=delete
 
 ValueByBlockCache (ValueByBlockCache &&)=delete
 
ValueByBlockCacheoperator= (const ValueByBlockCache &)=delete
 
ValueByBlockCacheoperator= (ValueByBlockCache &&)=delete
 
 ValueByBlockCache (uint64_t blocks_to_save, GetterFn &&getter_fn)
 
void append (uint64_t block_num, Value value) const
 
Value get (uint64_t block_num) const
 
Value last () 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 Value >
using taraxa::ValueByBlockCache< Value >::DataMap = std::map<uint64_t, Value>

◆ GetterFn

template<class Value >
using taraxa::ValueByBlockCache< Value >::GetterFn = std::function<Value(uint64_t)>

Constructor & Destructor Documentation

◆ ValueByBlockCache() [1/3]

template<class Value >
taraxa::ValueByBlockCache< Value >::ValueByBlockCache ( const ValueByBlockCache< Value > &  )
delete

◆ ValueByBlockCache() [2/3]

template<class Value >
taraxa::ValueByBlockCache< Value >::ValueByBlockCache ( ValueByBlockCache< Value > &&  )
delete

◆ ValueByBlockCache() [3/3]

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

Member Function Documentation

◆ append()

template<class Value >
void taraxa::ValueByBlockCache< Value >::append ( uint64_t  block_num,
Value  value 
) const
inline

◆ get()

template<class Value >
Value taraxa::ValueByBlockCache< Value >::get ( uint64_t  block_num) const
inline

◆ last()

template<class Value >
Value taraxa::ValueByBlockCache< Value >::last ( ) const
inline

◆ lastBlockNum()

template<class Value >
uint64_t taraxa::ValueByBlockCache< Value >::lastBlockNum ( ) const
inline

◆ operator=() [1/2]

template<class Value >
ValueByBlockCache& taraxa::ValueByBlockCache< Value >::operator= ( const ValueByBlockCache< Value > &  )
delete

◆ operator=() [2/2]

template<class Value >
ValueByBlockCache& taraxa::ValueByBlockCache< Value >::operator= ( ValueByBlockCache< Value > &&  )
delete

Member Data Documentation

◆ data_by_block_

template<class Value >
DataMap taraxa::ValueByBlockCache< Value >::data_by_block_
mutableprotected

◆ getter_fn_

template<class Value >
GetterFn taraxa::ValueByBlockCache< Value >::getter_fn_
protected

◆ kBlocksToKeep

template<class Value >
const uint64_t taraxa::ValueByBlockCache< Value >::kBlocksToKeep
protected

◆ mutex_

template<class Value >
std::shared_mutex taraxa::ValueByBlockCache< Value >::mutex_
mutableprotected

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