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

ConstIndexIterator

typedef typename TimeIndex::const_iterator ConstIndexIterator;

IndexIterator

typedef typename TimeIndex::iterator IndexIterator;

Iterator

typedef typename Keys::iterator Iterator;

KeyExpire

typedef std::pair < TKey, Timespan > KeyExpire;

Keys

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

TimeIndex

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

Constructors

UniqueAccessExpireStrategy inline

UniqueAccessExpireStrategy();

Create an unique expire strategy.

Destructor

~UniqueAccessExpireStrategy inline

~UniqueAccessExpireStrategy();

Member Functions

onAdd inline

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

onClear inline

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

onGet inline

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

onIsValid inline

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

onRemove inline

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

onReplace inline

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