Poco

template < class TKey, class TValue >

class ExpireStrategy

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

Description

An ExpireStrategy implements time based expiration of cache entries

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

ExpireStrategy inline

ExpireStrategy(
    Timestamp::TimeDiff expireTimeInMilliSec
);

Create an expire strategy. Note that the smallest allowed caching time is 25ms. Anything lower than that is not useful with current operating systems.

Destructor

~ExpireStrategy inline

~ExpireStrategy();

Member Functions

onAdd inline

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

onClear inline

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

onGet inline

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

onIsValid inline

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

onRemove inline

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

onReplace inline

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

Variables

_expireTime protected

Timestamp::TimeDiff _expireTime;

_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