Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::LRUCache< Key, Value > Class Template Reference

#include <lru-cache.hh>

Public Member Functions

 LRUCache (size_t capacity)
void upsert (const Key &key, const Value &value)
bool erase (const Key &key)
std::optional< Valueget (const Key &key)
size_t size ()
void clear ()

Detailed Description

template<typename Key, typename Value>
class nix::LRUCache< Key, Value >

A simple least-recently used cache. Not thread-safe.

Member Function Documentation

◆ get()

template<typename Key, typename Value>
std::optional< Value > nix::LRUCache< Key, Value >::get ( const Key & key)
inline

Look up an item in the cache. If it exists, it becomes the most recently used item.

Move this item to the back of the LRU list.

◆ upsert()

template<typename Key, typename Value>
void nix::LRUCache< Key, Value >::upsert ( const Key & key,
const Value & value )
inline

Insert or upsert an item in the cache.

Retire the oldest item.


The documentation for this class was generated from the following file: