nfx-lrucache 0.1.1
High-performance C++20 thread-safe LRU cache with sliding expiration
Loading...
Searching...
No Matches
nfx::cache::CacheEntry Struct Referencefinal

Cache entry metadata with intrusive LRU list support. More...

#include <nfx/cache/LruCache.h>

Collaboration diagram for nfx::cache::CacheEntry:

Public Member Functions

 CacheEntry (std::chrono::milliseconds expiration=std::chrono::hours(1))
 Construct cache entry with specified expiration time.
bool isExpired () const noexcept
 Check if this cache entry has expired based on sliding expiration.
void touch () noexcept
 Update the last accessed timestamp to current time.

Public Attributes

std::chrono::steady_clock::time_point lastAccessed
 Timestamp of the last access to this cache entry.
std::chrono::milliseconds slidingExpiration
 Sliding expiration time for this specific entry.
std::size_t size { 1 }
 Size of this cache entry for memory accounting.
CacheEntrylruPrev { nullptr }
 Previous entry in the LRU doubly-linked list.
CacheEntrylruNext { nullptr }
 Next entry in the LRU doubly-linked list.
const void * keyPtr { nullptr }
 Pointer to the key for this cache entry.

Detailed Description

Cache entry metadata with intrusive LRU list support.

Definition at line 113 of file LruCache.h.

Constructor & Destructor Documentation

◆ CacheEntry()

nfx::cache::CacheEntry::CacheEntry ( std::chrono::milliseconds expiration = std::chrono::hours(1))
inline

Construct cache entry with specified expiration time.

Parameters
expirationSliding expiration time for this entry

Member Function Documentation

◆ isExpired()

bool nfx::cache::CacheEntry::isExpired ( ) const
inlinenodiscardnoexcept

Check if this cache entry has expired based on sliding expiration.

Returns
True if the entry has expired and should be evicted, false otherwise
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ touch()

void nfx::cache::CacheEntry::touch ( )
inlinenoexcept

Update the last accessed timestamp to current time.

Resets the sliding expiration timer for this cache entry

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ keyPtr

const void* nfx::cache::CacheEntry::keyPtr { nullptr }

Pointer to the key for this cache entry.

Definition at line 131 of file LruCache.h.

◆ lastAccessed

std::chrono::steady_clock::time_point nfx::cache::CacheEntry::lastAccessed

Timestamp of the last access to this cache entry.

Definition at line 116 of file LruCache.h.

◆ lruNext

CacheEntry* nfx::cache::CacheEntry::lruNext { nullptr }

Next entry in the LRU doubly-linked list.

Definition at line 128 of file LruCache.h.

◆ lruPrev

CacheEntry* nfx::cache::CacheEntry::lruPrev { nullptr }

Previous entry in the LRU doubly-linked list.

Definition at line 125 of file LruCache.h.

◆ size

std::size_t nfx::cache::CacheEntry::size { 1 }

Size of this cache entry for memory accounting.

Definition at line 122 of file LruCache.h.

◆ slidingExpiration

std::chrono::milliseconds nfx::cache::CacheEntry::slidingExpiration

Sliding expiration time for this specific entry.

Definition at line 119 of file LruCache.h.


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