# 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

UniqueAccessExpireStrategy();

Create an unique expire strategy.

## Destructor

### ~UniqueAccessExpireStrategy

~UniqueAccessExpireStrategy();

## Member Functions

### onAdd

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

### onClear

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

### onGet

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

### onIsValid

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

### onRemove

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

### onReplace

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