template<typename K, typename V>
eckit::Cache class

Public types

struct Entry
class Policy
using key_type = K
using value_type = V
using entry_type = Entry
using store_type = std::map<key_type, entry_type>

Constructors, destructors, conversion operators

Cache()
~Cache()

Public functions

auto insert(const K&, const V&) -> bool
auto update(const K&, const V&) -> bool
auto fetch(const K&, V&) -> bool
auto expire(const K&) -> bool
void purge()
evicts entries that are considered expired
void clear()
evicts all entries
auto valid(const K&) const -> bool
auto size() const -> size_t
void print(std::ostream&) const

Friends

auto operator<<(std::ostream& s, const Cache& p) -> std::ostream&

Function documentation

template<typename K, typename V>
bool eckit::Cache<K, V>::insert(const K&, const V&)

Returns true if object was correctly inserted, or false if key already existed and cannot be inserted

inserts an object in the cache

template<typename K, typename V>
bool eckit::Cache<K, V>::update(const K&, const V&)

Returns true if object existed and was updated, false if the object did not exist and was inserted

updates an object in the cache (or inserts if does not exist)

template<typename K, typename V>
bool eckit::Cache<K, V>::fetch(const K&, V&)

accesses an object in the cache

template<typename K, typename V>
bool eckit::Cache<K, V>::expire(const K&)

Returns true if object was present and is marked as expired

marks an object as expired

template<typename K, typename V>
bool eckit::Cache<K, V>::valid(const K&) const

Returns true if entry exists and is not expired in cache

template<typename K, typename V>
size_t eckit::Cache<K, V>::size() const

Returns the number of entries in the cache, expired or not