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

ConstIndexIterator

typedef typename TimeIndex::const_iterator ConstIndexIterator;

IndexIterator

typedef typename TimeIndex::iterator IndexIterator;

Iterator

typedef typename Keys::iterator Iterator;

Keys

typedef std::map < TKey, IndexIterator > Keys;

TimeIndex

typedef std::multimap < Timestamp, TKey > TimeIndex;

Constructors

UniqueExpireStrategy inline

UniqueExpireStrategy();

Create an unique expire strategy.

Destructor

~UniqueExpireStrategy inline

~UniqueExpireStrategy();

Member Functions

onAdd inline

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

onClear inline

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

onGet inline

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

onIsValid inline

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

onRemove inline

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

onReplace inline

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