|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
Thread-safe LRU cache with optional TTL support. More...
#include <lru_cache.h>
Classes | |
| struct | Stats |
Public Types | |
| using | Clock = std::chrono::steady_clock |
| using | TimePoint = Clock::time_point |
Public Member Functions | |
| LRUCache (const LRUCache &)=delete | |
| LRUCache (LRUCache &&)=delete | |
| LRUCache (size_t maxSize, int ttlSeconds=0) | |
| Construct an LRU cache. | |
| void | clear () |
| Clear all entries. | |
| bool | contains (const Key &key) const |
| Check if key exists and is not expired (without updating LRU order). | |
| bool | empty () const |
| Check if cache is empty. | |
| std::optional< Value > | get (const Key &key) |
| Get a value from the cache. | |
| Stats | getStats () const |
| Get cache statistics. | |
| size_t | maxSize () const |
| Get maximum capacity. | |
| LRUCache & | operator= (const LRUCache &)=delete |
| LRUCache & | operator= (LRUCache &&)=delete |
| size_t | pruneExpired () |
| Remove expired entries (useful for periodic cleanup). | |
| void | put (const Key &key, const Value &value) |
| Put a value in the cache. | |
| void | put (const Key &key, Value &&value) |
| Put a value using move semantics. | |
| bool | remove (const Key &key) |
| Remove a specific key from cache. | |
| void | resetStats () |
| Reset statistics counters. | |
| size_t | size () const |
| Get current number of entries. | |
Thread-safe LRU cache with optional TTL support.
| Key | Type of cache keys (must be hashable) |
| Value | Type of cached values |
Definition at line 43 of file lru_cache.h.
| using LRUCache< Key, Value >::Clock = std::chrono::steady_clock |
Definition at line 46 of file lru_cache.h.
| using LRUCache< Key, Value >::TimePoint = Clock::time_point |
Definition at line 47 of file lru_cache.h.
|
inlineexplicit |
Construct an LRU cache.
| maxSize | Maximum number of entries (must be >= 1) |
| ttlSeconds | Time-to-live in seconds (0 = no expiration) |
Definition at line 54 of file lru_cache.h.
References maxSize().
Referenced by LRUCache(), LRUCache(), operator=(), and operator=().
|
delete |
References LRUCache().
|
delete |
References LRUCache().
|
inline |
Clear all entries.
Definition at line 211 of file lru_cache.h.
|
inline |
Check if key exists and is not expired (without updating LRU order).
Definition at line 174 of file lru_cache.h.
|
inline |
Check if cache is empty.
Definition at line 238 of file lru_cache.h.
|
inline |
Get a value from the cache.
| key | Key to look up |
Moves the accessed entry to the front (most recently used).
Definition at line 72 of file lru_cache.h.
Get cache statistics.
Definition at line 267 of file lru_cache.h.
|
inline |
|
delete |
References LRUCache().
|
delete |
References LRUCache().
|
inline |
Remove expired entries (useful for periodic cleanup).
Definition at line 286 of file lru_cache.h.
|
inline |
Put a value in the cache.
| key | Key to store under |
| value | Value to cache |
If key exists, updates the value and moves to front. If cache is full, evicts the least recently used entry.
Definition at line 115 of file lru_cache.h.
|
inline |
Put a value using move semantics.
Definition at line 146 of file lru_cache.h.
|
inline |
Remove a specific key from cache.
Definition at line 195 of file lru_cache.h.
|
inline |
Reset statistics counters.
Definition at line 276 of file lru_cache.h.
|
inline |
Get current number of entries.
Definition at line 221 of file lru_cache.h.