# Poco

# template < class TKey, class TValue >

# class LRUStrategy

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

## Description

An LRUStrategy implements least recently used cache replacement.

## Inheritance

Direct Base Classes: AbstractStrategy < TKey, TValue >

All Base Classes: AbstractStrategy < TKey, TValue >

## Member Summary

Member Functions: onAdd, onClear, onGet, onIsValid, onRemove, onReplace

## Types Aliases

### ConstIndexIterator

using ConstIndexIterator = typename KeyIndex::const_iterator;

### ConstIterator

using ConstIterator = typename Keys::const_iterator;

### IndexIterator

using IndexIterator = typename KeyIndex::iterator;

### Iterator

using Iterator = typename Keys::iterator;

### KeyIndex

using KeyIndex = std::map < TKey, Iterator >;

### Keys

using Keys = std::list < TKey >;

## Constructors

### LRUStrategy

LRUStrategy(
std::size_t size
);

## Destructor

### ~LRUStrategy

~LRUStrategy() = default;

## Member Functions

### onAdd

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

### onClear

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

### onGet

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

### onIsValid

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

### onRemove

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

### onReplace

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

## Variables

### _keyIndex

KeyIndex _keyIndex;

For faster access to _keys

### _keys

Keys _keys;

### _size

std::size_t _size;

Number of keys the cache can store.