Cascade
Loading...
Searching...
No Matches
Buzzware.Cascade.ModelClassCache< Model, IdType > Class Template Reference

A memory based cache for a given model type designed to store and retrieve instances of models and collections of ids with associated arrival timestamps. More...

Inheritance diagram for Buzzware.Cascade.ModelClassCache< Model, IdType >:
Buzzware.Cascade.IModelClassCache

Public Member Functions

 ModelClassCache ()
 ModelClassCache Constructor.
async Task Setup ()
 Implement this for any setup required.
async Task< OpResponseFetch (RequestOp requestOp)
 Fetches the requested model or collection from the cache if available and fresh enough; otherwise returns a none response to indicate a miss.
async Task< Model?> Fetch< Model > (object id, int freshnessSeconds=0)
 Fetches a model instance from the cache if available and within freshness period.
async Task Store (object id, object model, long arrivedAt)
 Stores a model instance in the cache with the arrived timestamp.
async Task StoreAll (IReadOnlyList< object > results, long arrivedAt)
async Task StoreCollection (string key, IEnumerable ids, long arrivedAt)
 Stores a collection of ids in the cache with the specified name key and arrived timestamp.
Task Remove (object id)
 Removes a model instance from the cache based on the given id.
async Task Remove (IdType id)
 Removes a model instance from the cache using the typed id.
async Task ClearAll (bool exceptHeld, DateTime? olderThan=null)
 Clears all models and collections from the cache, optionally holding certain elements if specified.

Properties

CascadeDataLayer Cascade [get, set]
 Reference to the CascadeDataLayer.

Detailed Description

A memory based cache for a given model type designed to store and retrieve instances of models and collections of ids with associated arrival timestamps.

Type Constraints
Model :class 

Member Function Documentation

◆ ClearAll()

async Task Buzzware.Cascade.ModelClassCache< Model, IdType >.ClearAll ( bool exceptHeld,
DateTime? olderThan = null )
inline

Clears all models and collections from the cache, optionally holding certain elements if specified.

Parameters
exceptHeldIndicates whether to exclude certain held items from clearing.
olderThanOptionally specifies a date threshold to restrict which items are cleared.

Implements Buzzware.Cascade.IModelClassCache.

◆ Fetch()

async Task< OpResponse > Buzzware.Cascade.ModelClassCache< Model, IdType >.Fetch ( RequestOp requestOp)
inline

Fetches the requested model or collection from the cache if available and fresh enough; otherwise returns a none response to indicate a miss.

Parameters
requestOpThe operation object containing request details for fetching data.
Returns
An OpResponse object containing details about the request result.

Implements Buzzware.Cascade.IModelClassCache.

◆ Fetch< Model >()

async Task< Model?> Buzzware.Cascade.ModelClassCache< Model, IdType >.Fetch< Model > ( object id,
int freshnessSeconds = 0 )
inline

Fetches a model instance from the cache if available and within freshness period.

Template Parameters
ModelThe type of model being requested.
Parameters
idThe identifier for the model instance.
freshnessSecondsThe maximum acceptable age of the cached data in seconds.
Returns
The model instance if found and fresh enough, otherwise null.
Type Constraints
Model :class 

◆ Remove() [1/2]

async Task Buzzware.Cascade.ModelClassCache< Model, IdType >.Remove ( IdType id)
inline

Removes a model instance from the cache using the typed id.

Parameters
idThe strongly typed identifier of the model to remove.

◆ Remove() [2/2]

Task Buzzware.Cascade.ModelClassCache< Model, IdType >.Remove ( object id)
inline

Removes a model instance from the cache based on the given id.

Parameters
idThe identifier of the model to remove.
Returns

Implements Buzzware.Cascade.IModelClassCache.

◆ Setup()

async Task Buzzware.Cascade.ModelClassCache< Model, IdType >.Setup ( )
inline

Implement this for any setup required.

Returns

Implements Buzzware.Cascade.IModelClassCache.

◆ Store()

async Task Buzzware.Cascade.ModelClassCache< Model, IdType >.Store ( object id,
object model,
long arrivedAt )
inline

Stores a model instance in the cache with the arrived timestamp.

Parameters
idThe identifier representing the model.
modelThe model object to be stored.
arrivedAtThe timestamp when the model data was obtained.

Implements Buzzware.Cascade.IModelClassCache.

◆ StoreAll()

async Task Buzzware.Cascade.ModelClassCache< Model, IdType >.StoreAll ( IReadOnlyList< object > results,
long arrivedAt )
inline

◆ StoreCollection()

async Task Buzzware.Cascade.ModelClassCache< Model, IdType >.StoreCollection ( string key,
IEnumerable ids,
long arrivedAt )
inline

Stores a collection of ids in the cache with the specified name key and arrived timestamp.

Parameters
keyA unique key identifying the collection.
idsThe enumerable collection of model identifiers.
arrivedAtThe timestamp when the collection data was obtained.

Implements Buzzware.Cascade.IModelClassCache.

Property Documentation

◆ Cascade

CascadeDataLayer Buzzware.Cascade.ModelClassCache< Model, IdType >.Cascade
getset

Reference to the CascadeDataLayer.

Implements Buzzware.Cascade.IModelClassCache.


The documentation for this class was generated from the following file:
  • Buzzware.Cascade/ModelClassCache.cs