Class Poco::ExpireStrategy
Author: Applied Informatics Software Engineering GmbH and Contributors
Date: 2009-11-24

# 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

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

~ExpireStrategy();

## Member Functions

### onAdd

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

### onClear

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

### onGet

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

### onIsValid

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

### onRemove

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

### onReplace

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

## Variables

### _expireTime

Timestamp::TimeDiff _expireTime;

### _keyIndex

TimeIndex _keyIndex;

Maps time to key value

### _keys

Keys _keys;

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