|
void | Insert (const Key &key) override |
| Handle element insertion in a cache.
|
|
void | Touch (const Key &key) override |
| Handle request to the key-element in a cache.
|
|
void | Erase (const Key &) noexcept override |
| Handle element deletion from a cache.
|
|
const Key & | ReplCandidate () const noexcept override |
| Return a key of a replacement candidate.
|
|
virtual void | Insert (const Key &key)=0 |
| Handle element insertion in a cache.
|
|
virtual void | Touch (const Key &key)=0 |
| Handle request to the key-element in a cache.
|
|
virtual void | Erase (const Key &key)=0 |
| Handle element deletion from a cache.
|
|
virtual const Key & | ReplCandidate () const =0 |
| Return a key of a replacement candidate.
|
|
template<typename Key>
class caches::LRUCachePolicy< Key >
LRU (Least Recently Used) cache policy.
LRU policy in the case of replacement removes the least recently used element. That is, in the case of replacement necessity, that cache policy returns a key that has not been touched recently. For example, cache maximum size is 3 and 3 elements have been added - A
, B
, C
. Then the following actions were made:
Cache placement order: A, B, C
Cache elements: A, B, C
# Cache access:
- A touched, B touched
# LRU element in the cache: C
# Cache access:
- B touched, C touched
# LRU element in the cache: A
# Put new element: D
# LRU replacement candidate: A
Cache elements: B, C, D
- Template Parameters
-
Key | Type of a key a policy works with |