|
nfx-lrucache 0.1.1
High-performance C++20 thread-safe LRU cache with sliding expiration
|
Thread-safe memory cache with size limits and expiration policies. More...
#include <nfx/cache/LruCache.h>
Public Types | |
| using | FactoryFunction = std::function<TValue()> |
| Function type for creating cache values when not found. | |
| using | ConfigFunction = std::function<void( CacheEntry& )> |
| Function type for configuring cache entry metadata. | |
Public Member Functions | |
| LruCache (const LruCacheOptions &options={}) | |
| Construct memory cache with specified options. | |
| LruCache (const LruCache &)=delete | |
| LruCache (LruCache &&)=delete | |
| LruCache & | operator= (const LruCache &)=delete |
| LruCache & | operator= (LruCache &&)=delete |
| TValue * | get (const TKey &key, FactoryFunction factory, ConfigFunction configure=nullptr) |
| Get a cache entry, creating it with factory function if not found. | |
| TValue * | find (const TKey &key) |
| Find a cached value without creating it. | |
| bool | remove (const TKey &key) |
| Remove an entry from the cache. | |
| void | clear () |
| Clear all cache entries. | |
| std::size_t | size () const |
| Get current cache size. | |
| bool | isEmpty () const |
| Check if cache is empty. | |
| void | cleanupExpired () |
| Manually trigger cleanup of expired entries. | |
Thread-safe memory cache with size limits and expiration policies.
| TKey | Key type for cache entries |
| TValue | Value type for cached objects |
Definition at line 175 of file LruCache.h.
| using nfx::cache::LruCache< TKey, TValue >::ConfigFunction = std::function<void( CacheEntry& )> |
Function type for configuring cache entry metadata.
Definition at line 186 of file LruCache.h.
| using nfx::cache::LruCache< TKey, TValue >::FactoryFunction = std::function<TValue()> |
Function type for creating cache values when not found.
Definition at line 183 of file LruCache.h.
|
inlineexplicit |
Construct memory cache with specified options.
| options | Configuration options for cache behavior |
|
inline |
Find a cached value without creating it.
| key | The cache key |
|
inline |
Get a cache entry, creating it with factory function if not found.
| key | The cache key |
| factory | Function to create the value if not cached |
| configure | Optional function to configure cache entry |
|
inline |
Check if cache is empty.
|
inline |
Remove an entry from the cache.
| key | The cache key to remove |
|
inline |
Get current cache size.