ExpiredCacheReloader

Base class for a cache. To use it you need to inherit it and override getData method. It operates only on contiguous struct buffers and does a copy of such buffer before returning cache element.

Recommended code pattern is to have a shared Cache but a fiber-local CachingStructLoader so that last accessed element won't become invalidated between context switches

Constructors

this
this(Cache cache_)

Constructor

Members

Aliases

opBinaryRight
alias opBinaryRight(istring op : "in") = opIn_r

Support for the 'in' operator

Classes

Cache
class Cache

The cache class. We need to enable GC scanning of the values stored in the cache because they contain references.

Functions

getData
void getData(hash_t key, void delegate(Contiguous!(S) data) got)

Looks up the record value corresponding to key and invokes got with either that value, if found, or empty data if not found. Should return without calling got if unable to look up the value.

load
Contiguous!(S) load(hash_t key)

Gets the record value corresponding to key.

onStoringData
void onStoringData(Contiguous!(S) data)

This method is called before storing new entry into the cache. It can be used to do any adjustments necessary for specific cached type. Does nothing by default which is most common case for exsting caches.

opIn_r
S* opIn_r(hash_t key)

Gets the record value corresponding to key.

Variables

cache
IExpiringCacheInfo cache;

Info interface for the cache instance is exposed to the public.

Parameters

S

type of the deserialized struct expected in contiguous buffer

Meta