Provides a file based IModelClassCache which stores serialized model classes and their collections in directory-based file storage. It uses hashing and memory storage to speed up some reads and writes.
More...
|
| | FastFileClassCache (string fileDir, CascadeJsonSerialization? serialization=null) |
| | Initializes a FastFileClassCache instance.
|
| string | GetModelFilePath (object? id=null) |
| | Retrieves the complete file path for a model, optionally including the specified ID.
|
| T? | DeserializeCacheString< T > (string? content) |
| | Deserializes a cached string into an object of type T.
|
| FastFileCacheRecord? | FetchFullRecord (string path) |
| | Retrieves a complete FastFileCacheRecord, loading content from the file if necessary, and keeps the cache updated.
|
| string? | FetchString (string path) |
| | Fetches the cached string content from a specified path.
|
| Task< OpResponse > | Fetch (RequestOp requestOp) |
| | Asynchronously fetches an object using a specified RequestOp, handling the operation depending on the verb.
|
| async Task | Setup () |
| | Implement this for any setup required.
|
| async Task | Store (object id, object model, long arrivedAt) |
| | Stores a given model object identified by a specific id with a timestamp.
|
| async Task | StoreAll (IReadOnlyList< object > results, long arrivedAt) |
| async Task | StoreCollection (string key, IEnumerable ids, long arrivedAt) |
| | Stores a collection of ids identified by a specific key with a timestamp.
|
| async Task | Remove (object id) |
| | Removes a model identified by a specific id from both the cache and the file system.
|
| async Task | ClearAll (bool exceptHeld, DateTime? olderThan=null) |
| | Clears all cached entries, optionally preserving specific entries based on held status or last-modified dates which can be older than a defined point-in-time.
|
|
| string | GetModelPath (object? id=null) |
| | Retrieves the storage path of all models for the class, or one with the specified id.
|
| string | GetCollectionPath (string? key=null) |
| | Retrieves the storage path for all collections, or one with the given key.
|
| string | ToFilePath (string path) |
| | Transforms a given relative path into a full file path using the base directory.
|
| string | GetCollectionFilePath (string? key=null) |
| | Retrieves the complete file path for a collection, optionally including the specified key.
|
| uint | HashAnyString (string? s) |
| | Computes a hash from the given string using FNVHash algorithm.
|
| void | StoreString (string path, long timeMs, string content) |
| | Stores the given string in cache and writes it to a file while ensuring consistency with file operations in case of an update.
|
| async Task | SerializeToPathAsync (string aPath, object aObject, long timeMs) |
| | Asynchronously serializes an object to a specified path with a given timestamp.
|
| async Task< T?> | DeserializeFromPathAsync< T > (string aPath) |
| | Asynchronously deserializes content from a specified path into an object of type T.
|
|
|
const int | MAX_STORED_LENGTH = 255 |
|
|
record | FastFileCacheRecord |
| | Represents a memory record in the internal cache.
|
| CascadeDataLayer? | Cascade [get, set] |
| | CascadeDataLayer reference.
|
Provides a file based IModelClassCache which stores serialized model classes and their collections in directory-based file storage. It uses hashing and memory storage to speed up some reads and writes.
◆ ClearAll()
| async Task Buzzware.Cascade.FastFileClassCache< Model, IdType >.ClearAll |
( |
bool | exceptHeld, |
|
|
DateTime? | olderThan = null ) |
|
inline |
Clears all cached entries, optionally preserving specific entries based on held status or last-modified dates which can be older than a defined point-in-time.
- Parameters
-
| exceptHeld | If true, preserves held models and collections. |
| olderThan | Optional DateTime specifying the threshold for removal based on last-modified time. |
Implements Buzzware.Cascade.IModelClassCache.
◆ DeserializeCacheString< T >()
| T? Buzzware.Cascade.FastFileClassCache< Model, IdType >.DeserializeCacheString< T > |
( |
string? | content | ) |
|
|
inline |
Deserializes a cached string into an object of type T.
- Template Parameters
-
| T | The model type into which the string is deserialized. |
- Parameters
-
| content | The string content to be deserialized. |
- Returns
- An instance of type T restored from the content, or default if content is null or empty.
◆ DeserializeFromPathAsync< T >()
| async Task< T?> Buzzware.Cascade.FastFileClassCache< Model, IdType >.DeserializeFromPathAsync< T > |
( |
string | aPath | ) |
|
|
inlineprotected |
Asynchronously deserializes content from a specified path into an object of type T.
- Template Parameters
-
| T | The model type into which the content should be deserialized. |
- Parameters
-
| aPath | Path from where the content is loaded for deserialization. |
- Returns
- An instance of type T, or null if deserialization fails.
◆ FastFileClassCache()
| Buzzware.Cascade.FastFileClassCache< Model, IdType >.FastFileClassCache |
( |
string | fileDir, |
|
|
CascadeJsonSerialization? | serialization = null ) |
|
inline |
Initializes a FastFileClassCache instance.
- Parameters
-
| fileDir | The directory path where model and collection files are stored. |
| serialization | Optional Cascade JSON serializer - created internally if not provided |
◆ Fetch()
| Task< OpResponse > Buzzware.Cascade.FastFileClassCache< Model, IdType >.Fetch |
( |
RequestOp | requestOp | ) |
|
|
inline |
Asynchronously fetches an object using a specified RequestOp, handling the operation depending on the verb.
- Parameters
-
| requestOp | The operation request defining the type, verb, and key/id for the fetch operation. |
- Returns
- An OpResponse containing the result or indicating none found.
Implements Buzzware.Cascade.IModelClassCache.
◆ FetchFullRecord()
| FastFileCacheRecord? Buzzware.Cascade.FastFileClassCache< Model, IdType >.FetchFullRecord |
( |
string | path | ) |
|
|
inline |
Retrieves a complete FastFileCacheRecord, loading content from the file if necessary, and keeps the cache updated.
- Parameters
-
| path | The path for which the cache record is to be fetched. |
- Returns
- A FastFileCacheRecord including content if loaded or already cached, or null if not found.
◆ FetchString()
| string? Buzzware.Cascade.FastFileClassCache< Model, IdType >.FetchString |
( |
string | path | ) |
|
|
inline |
Fetches the cached string content from a specified path.
- Parameters
-
| path | The path from which the content is retrieved. |
- Returns
- The cached string content or null if not available.
◆ GetCollectionFilePath()
| string Buzzware.Cascade.FastFileClassCache< Model, IdType >.GetCollectionFilePath |
( |
string? | key = null | ) |
|
|
inlineprotected |
Retrieves the complete file path for a collection, optionally including the specified key.
- Parameters
-
| key | Optional key to specify a specific collection file. |
- Returns
- The full file path for a collection file.
◆ GetCollectionPath()
| string Buzzware.Cascade.FastFileClassCache< Model, IdType >.GetCollectionPath |
( |
string? | key = null | ) |
|
|
inlineprotected |
Retrieves the storage path for all collections, or one with the given key.
- Parameters
-
- Returns
- The relative path
◆ GetModelFilePath()
| string Buzzware.Cascade.FastFileClassCache< Model, IdType >.GetModelFilePath |
( |
object? | id = null | ) |
|
|
inline |
Retrieves the complete file path for a model, optionally including the specified ID.
- Parameters
-
| id | Optional object ID to specify a specific model file. |
- Returns
- The full file path for a model file.
◆ GetModelPath()
| string Buzzware.Cascade.FastFileClassCache< Model, IdType >.GetModelPath |
( |
object? | id = null | ) |
|
|
inlineprotected |
Retrieves the storage path of all models for the class, or one with the specified id.
- Parameters
-
| id | Optional object id to specify a specific model file. |
- Returns
- the relative path
◆ HashAnyString()
| uint Buzzware.Cascade.FastFileClassCache< Model, IdType >.HashAnyString |
( |
string? | s | ) |
|
|
inlineprotected |
Computes a hash from the given string using FNVHash algorithm.
- Parameters
-
| s | Input string for which hash is to be computed. |
- Returns
- A 32-bit unsigned integer representing the computed hash.
◆ Remove()
| async Task Buzzware.Cascade.FastFileClassCache< Model, IdType >.Remove |
( |
object | id | ) |
|
|
inline |
Removes a model identified by a specific id from both the cache and the file system.
- Parameters
-
| id | The identifier for the model to remove. |
Implements Buzzware.Cascade.IModelClassCache.
◆ SerializeToPathAsync()
| async Task Buzzware.Cascade.FastFileClassCache< Model, IdType >.SerializeToPathAsync |
( |
string | aPath, |
|
|
object | aObject, |
|
|
long | timeMs ) |
|
inlineprotected |
Asynchronously serializes an object to a specified path with a given timestamp.
- Parameters
-
| aPath | The destination path for storing the serialized object. |
| aObject | The object to be serialized. |
| timeMs | The timestamp to associate with the serialized content. |
◆ Setup()
| async Task Buzzware.Cascade.FastFileClassCache< Model, IdType >.Setup |
( |
| ) |
|
|
inline |
◆ Store()
| async Task Buzzware.Cascade.FastFileClassCache< Model, IdType >.Store |
( |
object | id, |
|
|
object | model, |
|
|
long | arrivedAt ) |
|
inline |
Stores a given model object identified by a specific id with a timestamp.
- Parameters
-
| id | The identifier for the model to be stored. |
| model | The model object to be serialized and stored. |
| arrivedAt | The timestamp in milliseconds when the model arrived. |
Implements Buzzware.Cascade.IModelClassCache.
◆ StoreAll()
| async Task Buzzware.Cascade.FastFileClassCache< Model, IdType >.StoreAll |
( |
IReadOnlyList< object > | results, |
|
|
long | arrivedAt ) |
|
inline |
◆ StoreCollection()
| async Task Buzzware.Cascade.FastFileClassCache< Model, IdType >.StoreCollection |
( |
string | key, |
|
|
IEnumerable | ids, |
|
|
long | arrivedAt ) |
|
inline |
Stores a collection of ids identified by a specific key with a timestamp.
- Parameters
-
| key | The key that identifies the collection to be stored. |
| ids | The collection of identifiers to store. |
| arrivedAt | The timestamp in milliseconds when the collection was established. |
Implements Buzzware.Cascade.IModelClassCache.
◆ StoreString()
| void Buzzware.Cascade.FastFileClassCache< Model, IdType >.StoreString |
( |
string | path, |
|
|
long | timeMs, |
|
|
string | content ) |
|
inlineprotected |
Stores the given string in cache and writes it to a file while ensuring consistency with file operations in case of an update.
- Parameters
-
| path | Relative path of where to store the content. |
| timeMs | Timestamp indicating when the content was received. |
| content | The content string to store. |
◆ ToFilePath()
| string Buzzware.Cascade.FastFileClassCache< Model, IdType >.ToFilePath |
( |
string | path | ) |
|
|
inlineprotected |
Transforms a given relative path into a full file path using the base directory.
- Parameters
-
| path | Relative path to be combined with the base directory. |
- Returns
- The complete file path.
◆ Cascade
The documentation for this class was generated from the following file:
- Buzzware.Cascade/FastFileClassCache.cs