Poco

template < class TKey, class TValue >

class UniqueAccessExpireStrategy

Library: Foundation
Package: Cache
Header: Poco/UniqueAccessExpireStrategy.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& getTimeout() const;

which returns the timespan for how long an object will be valid without being accessed.

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;

KeyExpire

using KeyExpire = std::pair < TKey, Timespan >;

Keys

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

TimeIndex

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

Constructors

UniqueAccessExpireStrategy

UniqueAccessExpireStrategy() = default;

Create an unique expire strategy.

Destructor

~UniqueAccessExpireStrategy

~UniqueAccessExpireStrategy() = default;

Member Functions

onAdd inline

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

onClear inline

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

onGet inline

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

onIsValid inline

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

onRemove inline

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

onReplace inline

void onReplace(
    const void * param416,
    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