AWS SDK for C++  1.9.128
AWS SDK for C++
Classes | Public Member Functions | List of all members
Aws::Utils::Cache< TKey, TValue > Class Template Reference

#include <Cache.h>

Public Member Functions

 Cache (size_t initialSize=1000)
 
bool Get (const TKey &key, TValue &value) const
 
template<typename UValue >
void Put (TKey &&key, UValue &&val, std::chrono::milliseconds duration)
 
template<typename UValue >
void Put (const TKey &key, UValue &&val, std::chrono::milliseconds duration)
 

Detailed Description

template<typename TKey, typename TValue>
class Aws::Utils::Cache< TKey, TValue >

In-memory fixed-size cache utility.

Definition at line 20 of file Cache.h.

Constructor & Destructor Documentation

◆ Cache()

template<typename TKey , typename TValue >
Aws::Utils::Cache< TKey, TValue >::Cache ( size_t  initialSize = 1000)
inlineexplicit

Initialize the cache with a particular size. The size of the cache is fixed and does not grow over time.

Definition at line 27 of file Cache.h.

Member Function Documentation

◆ Get()

template<typename TKey , typename TValue >
bool Aws::Utils::Cache< TKey, TValue >::Get ( const TKey &  key,
TValue &  value 
) const
inline

Retrieves the value associated with the given key if exists and returns true. Otherwise, returns false.

Parameters
keyThe of key of the entry to retrieve.
valueThe retrieved value in case the key exists in the cache

Definition at line 36 of file Cache.h.

◆ Put() [1/2]

template<typename TKey , typename TValue >
template<typename UValue >
void Aws::Utils::Cache< TKey, TValue >::Put ( const TKey &  key,
UValue &&  val,
std::chrono::milliseconds  duration 
)
inline

Definition at line 86 of file Cache.h.

◆ Put() [2/2]

template<typename TKey , typename TValue >
template<typename UValue >
void Aws::Utils::Cache< TKey, TValue >::Put ( TKey &&  key,
UValue &&  val,
std::chrono::milliseconds  duration 
)
inline

Add or update a cache entry. When the number of items in the cache reaches the maximum, newly added items will evict expired items. If the cache size is at its maximum and none of the existing items are expired, the entry that is closest to expiration will be evicted.

Note: Expired entries are not evicted upon expiration, but rather when space is needed for new items.

Parameters
keyThe of key of the entry that will be used to retrieve it.
valThe value of the entry to associate with the given key.
durationThe duration after which the cache entry will expire and become a candidate for eviction.

Definition at line 66 of file Cache.h.


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