Cascade
Loading...
Searching...
No Matches
Buzzware.Cascade.ModelCache Class Reference

Top level cache implementing ICascadeCache. This class manages an array of IModelClassCache, one per model class. The IModelClassCache implementations passed to the constructor can use any storage mechanism, and Cascade provides a few file and memory options. A IBlobCache can also be included to manage the storing, fetching, and clearing of binary blob data. More...

Inheritance diagram for Buzzware.Cascade.ModelCache:
Buzzware.Cascade.ICascadeCache

Public Member Functions

string? GetBlobAbsoluteFilePath (string blobPath)
 Given a blob path (always relative) return an absolute local file system path for that blob.
async Task ClearAll (bool exceptHeld=true, DateTime? olderThan=null)
async Task ClearByType (Type type, bool exceptHeld=true, DateTime? olderThan=null)
async Task ClearBlobs (bool exceptHeld=true, DateTime? olderThan=null)
async Task ClearBlob (string path)
Task NotifyBlobIsFresh (string blobPath, long arrivedAtMs)
 Set the ArrivedAtMs value for the given blobPath to the given value. This is not absolutely necessary but for maximum efficiency should be implemented. It is only used when eTags indicate that a local blob is still fresh.
 ModelCache (IDictionary< Type, IModelClassCache > aClassCache, IBlobCache? blobCache=null)
async Task< OpResponseFetch (RequestOp requestOp)
 Fetches data based on the specified request operation from the enclosed caches.
Task Store (Type type, object id, object model, long arrivedAt)
 Stores a model in the cache under the specified type, id, and arrival time.
Task StoreCollection (Type type, string key, IEnumerable ids, long arrivedAt)
 Stores a collection of model IDs in the cache under the given type and key.
async Task< OpResponseStore (OpResponse opResponse)
 Stores an operation response in the appropriate cache Manages storage differently depending on whether it's a Blob operation, single model, or a query collection.
Public Member Functions inherited from Buzzware.Cascade.ICascadeCache
Task StoreCollection (Type type, string key, IEnumerable? ids, long arrivedAt)
 Stores a collection of model ids in the cache.

Properties

CascadeDataLayer Cascade [get, set]
 CascadeDataLayer instance used by the ModelCache. When set, updates the Cascade instance for all class caches and the blob cache if available.
bool SupportsBlobs [get]
bool SupportsGetBlobAbsoluteFilePath [get]

Detailed Description

Top level cache implementing ICascadeCache. This class manages an array of IModelClassCache, one per model class. The IModelClassCache implementations passed to the constructor can use any storage mechanism, and Cascade provides a few file and memory options. A IBlobCache can also be included to manage the storing, fetching, and clearing of binary blob data.

Constructor & Destructor Documentation

◆ ModelCache()

Buzzware.Cascade.ModelCache.ModelCache ( IDictionary< Type, IModelClassCache > aClassCache,
IBlobCache? blobCache = null )
inline

ModelCache Constructor

Parameters
aClassCacheDictionary that provides the model class caches to be managed.
blobCacheOptional instance of a blob cache to be managed alongside the class caches.

Member Function Documentation

◆ ClearAll()

async Task Buzzware.Cascade.ModelCache.ClearAll ( bool exceptHeld = true,
DateTime? olderThan = null )
inline

Clears all cached data from class caches and the blob cache if specified. Can optionally protect held data and clear only data older than a certain date.

Parameters
exceptHeldFlag indicating whether to exclude held items from being cleared.
olderThanIf specified, only clear items older than this date/time.

Implements Buzzware.Cascade.ICascadeCache.

◆ ClearBlob()

async Task Buzzware.Cascade.ModelCache.ClearBlob ( string path)
inline

◆ ClearBlobs()

async Task Buzzware.Cascade.ModelCache.ClearBlobs ( bool exceptHeld = true,
DateTime? olderThan = null )
inline

◆ ClearByType()

async Task Buzzware.Cascade.ModelCache.ClearByType ( Type type,
bool exceptHeld = true,
DateTime? olderThan = null )
inline

◆ Fetch()

async Task< OpResponse > Buzzware.Cascade.ModelCache.Fetch ( RequestOp requestOp)
inline

Fetches data based on the specified request operation from the enclosed caches.

Parameters
requestOpThe operation request that specifies what data to fetch and how to do it.
Returns
OpResponse containing the result of the fetch operation and its metadata.

Implements Buzzware.Cascade.ICascadeCache.

◆ GetBlobAbsoluteFilePath()

string? Buzzware.Cascade.ModelCache.GetBlobAbsoluteFilePath ( string blobPath)
inline

Given a blob path (always relative) return an absolute local file system path for that blob.

Parameters
blobPath
Returns

Implements Buzzware.Cascade.ICascadeCache.

◆ NotifyBlobIsFresh()

Task Buzzware.Cascade.ModelCache.NotifyBlobIsFresh ( string blobPath,
long arrivedAtMs )
inline

Set the ArrivedAtMs value for the given blobPath to the given value. This is not absolutely necessary but for maximum efficiency should be implemented. It is only used when eTags indicate that a local blob is still fresh.

Parameters
blobPath
arrivedAtMs
Returns

Implements Buzzware.Cascade.ICascadeCache.

◆ Store() [1/2]

async Task< OpResponse > Buzzware.Cascade.ModelCache.Store ( OpResponse opResponse)
inline

Stores an operation response in the appropriate cache Manages storage differently depending on whether it's a Blob operation, single model, or a query collection.

Parameters
opResponseThe response of an operation that provides details about what to store.

Implements Buzzware.Cascade.ICascadeCache.

◆ Store() [2/2]

Task Buzzware.Cascade.ModelCache.Store ( Type type,
object id,
object model,
long arrivedAt )
inline

Stores a model in the cache under the specified type, id, and arrival time.

Parameters
typeThe type of the model being stored.
idThe id of the model.
modelThe model instance to store.
arrivedAtTimestamp representing when the data arrived from the origin

Implements Buzzware.Cascade.ICascadeCache.

◆ StoreCollection()

Task Buzzware.Cascade.ModelCache.StoreCollection ( Type type,
string key,
IEnumerable ids,
long arrivedAt )
inline

Stores a collection of model IDs in the cache under the given type and key.

Parameters
typeThe type of the models being stored.
keyThe key to associate with the collection of model IDs.
idsThe collection of model IDs to store.
arrivedAtTimestamp indicating when the collection was captured, in ms since 1970

Property Documentation

◆ Cascade

CascadeDataLayer Buzzware.Cascade.ModelCache.Cascade
getset

CascadeDataLayer instance used by the ModelCache. When set, updates the Cascade instance for all class caches and the blob cache if available.

Implements Buzzware.Cascade.ICascadeCache.

◆ SupportsBlobs

bool Buzzware.Cascade.ModelCache.SupportsBlobs
get

◆ SupportsGetBlobAbsoluteFilePath

bool Buzzware.Cascade.ModelCache.SupportsGetBlobAbsoluteFilePath
get

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