# 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

UniqueExpireStrategy();

Create an unique expire strategy.

## Destructor

### ~UniqueExpireStrategy

~UniqueExpireStrategy();

## Member Functions

### onAdd

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

### onClear

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

### onGet

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

### onIsValid

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

### onRemove

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

### onReplace

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

## Variables

### _keyIndex

TimeIndex _keyIndex;

Maps time to key value

### _keys

Keys _keys;

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