LRUCache

Data cache class template. Stores items of raw data, either of fixed or dynamic size.

Constructors

this
this(size_t max_items)

Constructor.

Members

Aliases

Value
alias Value = ValueT!(T, TrackCreateTimes)

An alias for the type stored in PriorityCache.

Functions

getAndRefresh
T* getAndRefresh(hash_t key, time_t access_time)

Gets an item from the cache. A pointer to the item is returned, if found. If the item exists in the cache, its update time is updated.

getAndRefresh
T* getAndRefresh(hash_t key)

Gets an item from the cache. A pointer to the item is returned, if found. If the item exists in the cache, its update time is updated.

getAndRefreshRaw
Value* getAndRefreshRaw(hash_t key, time_t access_time)

Gets an item from the cache. A pointer to the item is returned, if found. If the item exists in the cache, its update time is updated.

getRefreshOrCreate
T* getRefreshOrCreate(hash_t key)

Gets an item from the cache or creates it if not already existing. If the item exists in the cache, its update time is updated, otherwise its create time is set.

getRefreshOrCreate
T* getRefreshOrCreate(hash_t key, bool existed)

Gets an item from the cache or creates it if not already existing. If the item was found in the cache, its access time is updated, otherwise its create time is set.

getRefreshOrCreate
T* getRefreshOrCreate(hash_t key, time_t access_time, bool existed)

Gets an item from the cache or creates it if not already existing. If the item was found in the cache, its access time is updated, otherwise its create time is set.

getRefreshOrCreateRaw
Value* getRefreshOrCreateRaw(hash_t key, time_t access_time, bool existed)

Gets an item from the cache or creates it if not already existing. If the item was found in the cache, its access time is updated, otherwise its create time is set.

now
time_t now()

Obtains the current time. By default this is the wall clock time in seconds. This time value is used to find the least recently updated cache item and stored as create time. A subclass may override this method to use a different time unit or clock.

put
bool put(hash_t key, T value)

Puts an item into the cache. If the cache is full, the oldest item is replaced with the new item. (In the case where several items are equally old, the choice of which one to be replaced is made arbitrarily.)

Parameters

T

type of item to store in cache

TrackCreateTimes

if true, each cache item is stored with its create time, in addition to its last access time

Meta