TARAXA
ExpirationBlockNumberCache< Key > Class Template Reference

#include <util.hpp>

Collaboration diagram for ExpirationBlockNumberCache< Key >:

Public Member Functions

 ExpirationBlockNumberCache (uint32_t max_size, uint32_t delete_step, uint32_t blocks_to_keep)
 
bool insert (Key const &key, uint64_t block_number)
 Inserts key into the cache map. In case provided key is already in cache, only shared lock is acquired and function returns false. This means insert does not need to be used together with count() to save the performance by not acquiring unique lock. More...
 
void clear ()
 
- Public Member Functions inherited from ExpirationCache< Key >
 ExpirationCache (uint32_t max_size, uint32_t delete_step)
 
bool insert (Key const &key)
 Inserts key into the cache map. In case provided key is already in cache, only shared lock is acquired and function returns false. This means insert does not need to be used together with count() to save the performance by not acquiring unique lock. More...
 
bool contains (Key const &key) const
 
void erase (Key const &key)
 
std::size_t count (Key const &key) const
 
std::size_t size () const
 
void clear ()
 

Private Attributes

std::deque< std::pair< Key, uint64_t > > block_expiration_
 
const uint32_t kBlocksToKeep
 
uint64_t last_block_number_ = 0
 

Additional Inherited Members

- Protected Attributes inherited from ExpirationCache< Key >
std::unordered_set< Key > cache_
 
const uint32_t kMaxSize
 
const uint32_t kDeleteStep
 
std::shared_mutex mtx_
 

Constructor & Destructor Documentation

◆ ExpirationBlockNumberCache()

template<class Key >
ExpirationBlockNumberCache< Key >::ExpirationBlockNumberCache ( uint32_t  max_size,
uint32_t  delete_step,
uint32_t  blocks_to_keep 
)
inline

Member Function Documentation

◆ clear()

template<class Key >
void ExpirationBlockNumberCache< Key >::clear ( )
inline

◆ insert()

template<class Key >
bool ExpirationBlockNumberCache< Key >::insert ( Key const &  key,
uint64_t  block_number 
)
inline

Inserts key into the cache map. In case provided key is already in cache, only shared lock is acquired and function returns false. This means insert does not need to be used together with count() to save the performance by not acquiring unique lock.

Parameters
key
block_number
Returns
true if actual insertion took place, otherwise false

Member Data Documentation

◆ block_expiration_

template<class Key >
std::deque<std::pair<Key, uint64_t> > ExpirationBlockNumberCache< Key >::block_expiration_
private

◆ kBlocksToKeep

template<class Key >
const uint32_t ExpirationBlockNumberCache< Key >::kBlocksToKeep
private

◆ last_block_number_

template<class Key >
uint64_t ExpirationBlockNumberCache< Key >::last_block_number_ = 0
private

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