Poco

template < class TKey, class TValue >

class UniqueExpireStrategy

Library: Foundation
Package: Cache
Header: Poco/UniqueExpireStrategy.h

Description

An UniqueExpireStrategy implements time based expiration of cache entries. In contrast to ExpireStrategy which only allows to set a per cache expiration value, it allows to define expiration per CacheEntry. Each TValue object must thus offer the following method:

const Poco::Timestamp& getExpiration() const;

which returns the absolute timepoint when the entry will be invalidated.

Inheritance

Direct Base Classes: AbstractStrategy < TKey, TValue >

All Base Classes: AbstractStrategy < TKey, TValue >

Member Summary

Member Functions: onAdd, onClear, onGet, onIsValid, onRemove, onReplace

Types Aliases

ConstIndexIterator

using ConstIndexIterator = typename TimeIndex::const_iterator;

IndexIterator

using IndexIterator = typename TimeIndex::iterator;

Iterator

using Iterator = typename Keys::iterator;

Keys

using Keys = std::map < TKey, IndexIterator >;

TimeIndex

using TimeIndex = std::multimap < Timestamp, TKey >;

Constructors

UniqueExpireStrategy

UniqueExpireStrategy() = default;

Create an unique expire strategy.

Destructor

~UniqueExpireStrategy

~UniqueExpireStrategy() = default;

Member Functions

onAdd inline

void onAdd(
    const void * param417,
    const KeyValueArgs < TKey, TValue > & args
);

onClear inline

void onClear(
    const void * param420,
    const EventArgs & args
);

onGet inline

void onGet(
    const void * param419,
    const TKey & key
);

onIsValid inline

void onIsValid(
    const void * param421,
    ValidArgs < TKey > & args
);

onRemove inline

void onRemove(
    const void * param418,
    const TKey & key
);

onReplace inline

void onReplace(
    const void * param422,
    std::set < TKey > & elemsToRemove
);

Variables

_keyIndex protected

TimeIndex _keyIndex;

Maps time to key value

_keys protected

Keys _keys;

For faster replacement of keys, the iterator points to the _keyIndex map