Kagome
Polkadot Runtime Engine in C++17
kagome::runtime::SmallLruCache< Key, Value, PriorityType > Struct Template Referencefinal

#include <runtime_instances_pool.hpp>

Collaboration diagram for kagome::runtime::SmallLruCache< Key, Value, PriorityType >:

Classes

struct  CacheEntry
 

Public Member Functions

 SmallLruCache (size_t max_size)
 
std::optional< std::reference_wrapper< const Value > > get (const Key &key)
 
template<typename ValueArg >
void put (const Key &key, ValueArg &&value)
 

Private Member Functions

void handleTicksOverflow ()
 

Private Attributes

const size_t kMaxSize
 
PriorityType ticks_ {}
 
std::vector< CacheEntrycache_
 

Detailed Description

template<typename Key, typename Value, typename PriorityType = uint64_t>
struct kagome::runtime::SmallLruCache< Key, Value, PriorityType >

LRU cache designed for small amounts of data (as its get() is O(N))

Definition at line 18 of file runtime_instances_pool.hpp.

Constructor & Destructor Documentation

template<typename Key , typename Value , typename PriorityType = uint64_t>
kagome::runtime::SmallLruCache< Key, Value, PriorityType >::SmallLruCache ( size_t  max_size)
inline

Definition at line 32 of file runtime_instances_pool.hpp.

Member Function Documentation

template<typename Key , typename Value , typename PriorityType = uint64_t>
std::optional<std::reference_wrapper<const Value> > kagome::runtime::SmallLruCache< Key, Value, PriorityType >::get ( const Key &  key)
inline

Definition at line 37 of file runtime_instances_pool.hpp.

template<typename Key , typename Value , typename PriorityType = uint64_t>
void kagome::runtime::SmallLruCache< Key, Value, PriorityType >::handleTicksOverflow ( )
inlineprivate

Definition at line 65 of file runtime_instances_pool.hpp.

template<typename Key , typename Value , typename PriorityType = uint64_t>
template<typename ValueArg >
void kagome::runtime::SmallLruCache< Key, Value, PriorityType >::put ( const Key &  key,
ValueArg &&  value 
)
inline

Definition at line 52 of file runtime_instances_pool.hpp.

Member Data Documentation

template<typename Key , typename Value , typename PriorityType = uint64_t>
std::vector<CacheEntry> kagome::runtime::SmallLruCache< Key, Value, PriorityType >::cache_
private

Definition at line 79 of file runtime_instances_pool.hpp.

template<typename Key , typename Value , typename PriorityType = uint64_t>
const size_t kagome::runtime::SmallLruCache< Key, Value, PriorityType >::kMaxSize
private

Definition at line 75 of file runtime_instances_pool.hpp.

template<typename Key , typename Value , typename PriorityType = uint64_t>
PriorityType kagome::runtime::SmallLruCache< Key, Value, PriorityType >::ticks_ {}
private

Definition at line 78 of file runtime_instances_pool.hpp.


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