hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
iroha::cache::AbstractCache< KeyType, ValueType, T > Class Template Reference

#include "abstract_cache.hpp"

Collaboration diagram for iroha::cache::AbstractCache< KeyType, ValueType, T >:
Collaboration graph

Public Member Functions

uint32_t getIndexSizeHigh () const
 
uint32_t getIndexSizeLow () const
 
uint32_t getCacheItemCount () const
 
void addItem (const KeyType &key, const ValueType &value)
 
boost::optional< ValueType > findItem (const KeyType &key) const
 

Detailed Description

template<typename KeyType, typename ValueType, typename T>
class iroha::cache::AbstractCache< KeyType, ValueType, T >

Cache for any key-value types. Internally it uses a map to cache ItemTypes and linked list based index of KeyTypes to remove oldest items when getIndexSizeHigh() is reached. Implemented as a CRTP pattern.

Template Parameters
KeyType- type of cache keys
ValueType- type of cache values
T- type of implementation

Member Function Documentation

template<typename KeyType, typename ValueType, typename T>
void iroha::cache::AbstractCache< KeyType, ValueType, T >::addItem ( const KeyType &  key,
const ValueType &  value 
)
inline

Adds new item to cache. When amount of cache records reaches getIndexSizeHigh() a procedure of clean starts until getIndexSizeLow() records left. Note: cache does not have a remove method, deletion performs automatically. Since every add operation can potentially lead to deletion, it should be protected by mutex.

Parameters
key- key to insert
value- value to insert

Here is the caller graph for this function:

template<typename KeyType, typename ValueType, typename T>
boost::optional<ValueType> iroha::cache::AbstractCache< KeyType, ValueType, T >::findItem ( const KeyType &  key) const
inline

Performs a search for an item with a specific key.

Parameters
hash- key to find
Returns
Optional of ValueType

Here is the caller graph for this function:

template<typename KeyType, typename ValueType, typename T>
uint32_t iroha::cache::AbstractCache< KeyType, ValueType, T >::getCacheItemCount ( ) const
inline
Returns
amount of items in cache
template<typename KeyType, typename ValueType, typename T>
uint32_t iroha::cache::AbstractCache< KeyType, ValueType, T >::getIndexSizeHigh ( ) const
inline
Returns
high border of cache limit (
See also
AbstractCache::addItem)
template<typename KeyType, typename ValueType, typename T>
uint32_t iroha::cache::AbstractCache< KeyType, ValueType, T >::getIndexSizeLow ( ) const
inline
Returns
low border of cache limit (
See also
AbstractCache::addItem)

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