A simple file system-based cache for storing and retrieving instances of a model class with specified ID type. Implements IModelClassCache to fetch, store, and remove model instances and collections using JSON serialization.
More...
|
| | FileSystemClassCache (string fileDir, CascadeJsonSerialization? serialization=null) |
| | FileSystemClassCache Constructor Initializes directories for models and collections, and initializes the JSON serialization mechanism.
|
| async Task< OpResponse > | Fetch (RequestOp requestOp) |
| | Fetches a model or collection from the file system based on the specified request operation.
|
| async Task | Setup () |
| | Implement this for any setup required.
|
| async Task | Store (object id, object model, long arrivedAt) |
| | Stores a model instance asynchronously to the file system based on its id.
|
| async Task | StoreAll (IReadOnlyList< object > results, long arrivedAt) |
| async Task | StoreCollection (string key, IEnumerable ids, long arrivedAt) |
| | Stores a collection of model ids to the file system under a specific key.
|
| async Task | Remove (object id) |
| | Removes a model instance from the file system based on its identifier.
|
| async Task | ClearAll (bool exceptHeld, DateTime? olderThan=null) |
| | Clears all stored models and collections from the file system. Optionally exempts held or recently modified files.
|
|
| async Task | SerializeToPathAsync (string aPath, object aObject, long timeMs) |
| | Serializes an object to a specified file path asynchronously and sets the file's last write time.
|
| async Task< T?> | DeserializeFromPathAsync< T > (string aPath) |
| | Deserializes and returns an object from the given file path.
|
A simple file system-based cache for storing and retrieving instances of a model class with specified ID type. Implements IModelClassCache to fetch, store, and remove model instances and collections using JSON serialization.
◆ ClearAll()
| async Task Buzzware.Cascade.FileSystemClassCache< Model, IdType >.ClearAll |
( |
bool | exceptHeld, |
|
|
DateTime? | olderThan = null ) |
|
inline |
Clears all stored models and collections from the file system. Optionally exempts held or recently modified files.
- Parameters
-
| exceptHeld | If true, retains files marked as held in cache. |
| olderThan | Optional DateTime to retain files modified after a certain date. |
Implements Buzzware.Cascade.IModelClassCache.
◆ DeserializeFromPathAsync< T >()
| async Task< T?> Buzzware.Cascade.FileSystemClassCache< Model, IdType >.DeserializeFromPathAsync< T > |
( |
string | aPath | ) |
|
|
inlineprotected |
Deserializes and returns an object from the given file path.
- Template Parameters
-
| T | The type of the object to deserialize. |
- Parameters
-
| aPath | The path of the file from which to deserialize the object. |
- Returns
- The deserialized object of type T, or null if deserialization fails.
◆ Fetch()
| async Task< OpResponse > Buzzware.Cascade.FileSystemClassCache< Model, IdType >.Fetch |
( |
RequestOp | requestOp | ) |
|
|
inline |
Fetches a model or collection from the file system based on the specified request operation.
- Parameters
-
| requestOp | The operation that specifies what to fetch. |
- Returns
- Operation response containing the fetched object or a failed status if not found.
Implements Buzzware.Cascade.IModelClassCache.
◆ FileSystemClassCache()
| Buzzware.Cascade.FileSystemClassCache< Model, IdType >.FileSystemClassCache |
( |
string | fileDir, |
|
|
CascadeJsonSerialization? | serialization = null ) |
|
inline |
FileSystemClassCache Constructor Initializes directories for models and collections, and initializes the JSON serialization mechanism.
- Parameters
-
| fileDir | The base directory for storing model and collection files. |
| serialization | Optional JSON serialization object; uses default if not specified. |
◆ Remove()
| async Task Buzzware.Cascade.FileSystemClassCache< Model, IdType >.Remove |
( |
object | id | ) |
|
|
inline |
Removes a model instance from the file system based on its identifier.
- Parameters
-
| id | The identifier of the model instance to remove. |
Implements Buzzware.Cascade.IModelClassCache.
◆ SerializeToPathAsync()
| async Task Buzzware.Cascade.FileSystemClassCache< Model, IdType >.SerializeToPathAsync |
( |
string | aPath, |
|
|
object | aObject, |
|
|
long | timeMs ) |
|
inlineprotected |
Serializes an object to a specified file path asynchronously and sets the file's last write time.
- Parameters
-
| aPath | The target file path for serialized output. |
| aObject | The object to serialize. |
| timeMs | The timestamp in milliseconds to set as the file's last write time. |
◆ Setup()
| async Task Buzzware.Cascade.FileSystemClassCache< Model, IdType >.Setup |
( |
| ) |
|
|
inline |
◆ Store()
| async Task Buzzware.Cascade.FileSystemClassCache< Model, IdType >.Store |
( |
object | id, |
|
|
object | model, |
|
|
long | arrivedAt ) |
|
inline |
Stores a model instance asynchronously to the file system based on its id.
- Parameters
-
| id | Identifier of the model instance. |
| model | The model object to store. |
| arrivedAt | Timestamp of when the model arrived, used for file timestamping. |
Implements Buzzware.Cascade.IModelClassCache.
◆ StoreAll()
| async Task Buzzware.Cascade.FileSystemClassCache< Model, IdType >.StoreAll |
( |
IReadOnlyList< object > | results, |
|
|
long | arrivedAt ) |
|
inline |
◆ StoreCollection()
| async Task Buzzware.Cascade.FileSystemClassCache< Model, IdType >.StoreCollection |
( |
string | key, |
|
|
IEnumerable | ids, |
|
|
long | arrivedAt ) |
|
inline |
Stores a collection of model ids to the file system under a specific key.
- Parameters
-
| key | The key under which the collection is stored. |
| ids | The collection of identifiers to store. |
| arrivedAt | Timestamp of when the collection was stored, used for file timestamping. |
Implements Buzzware.Cascade.IModelClassCache.
◆ Cascade
| CascadeDataLayer? Buzzware.Cascade.FileSystemClassCache< Model, IdType >.Cascade |
|
getset |
The documentation for this class was generated from the following file:
- Buzzware.Cascade/FileSystemClassCache.cs