Appearance
Cache Class
Definition
Implementation of IMemoryCache supporting permanent, timebound, and filebased entries
- Namespace:
JASE - Assembly:
JASE.Caching.dll
Properties
| Name | Description |
|---|---|
Attempts | Number of Attempts to read items from Cache |
CapacityEvictions | Number of times a Cache item was evicted due to capacity |
Count | Returns the number of items in the cache |
DefaultTimeSpan | Returns the default TimeSpan for time based expiration |
Evictions | Number of times a Cache item went stale and was evicted |
HasSizeLimit | Reflects if the Memory Cache has a defined size limit |
Hits | Number of times Cache reads successfully returned data |
Stats | Gets a snapshot of current cache usage and eviction statistics |
Methods
| Name | Description |
|---|---|
string GenerateCacheKey(string prefix, object[] parts) | Generates a deterministic cache key by hashing a prefix together with the serialized parts. |
T Get(string key) | Retrieves an item from the cache cast to type of T. Returns the stored reference; the cache does not clone. Treat cached values as immutable, or take a copy at the call site if isolation is required. Cache key |
object Get(string key) | Retrieves an item from the Cache as an object. Returns the stored reference; the cache does not clone. Treat cached values as immutable, or take a copy at the call site if isolation is required. Cache key |
List<string> GetListKeys() | Returns a list of keys currently in the Cache object |
T GetOrInsert(string key, Func<T> factory) | Retrieves an item from the cache cast to type of T, or inserts using the provided Factory function |
T GetOrInsert(string key, Func<T> factory, TimeSpan expiration, bool sliding = null) | Retrieves an item from the cache cast to type of T, or inserts using the provided Factory function with TimeSpan expiration |
T GetOrInsert(string key, string filename, Func<T> factory) | Retrieves an item from the cache cast to type of T, or inserts using the provided Factory function and file dependency |
Task<T> GetOrInsertAsync(string key, Func<CancellationToken, Task<T>> factory, CancellationToken ct = null) | Retrieves an item from the cache cast to type of T, or inserts using the provided Factory function |
Task<T> GetOrInsertAsync(string key, Func<CancellationToken, Task<T>> factory, TimeSpan expiration, bool sliding = null, CancellationToken ct = null) | Retrieves an item from the cache cast to type of T, or inserts using the provided Factory function with TimeSpan expiration |
Task<T> GetOrInsertAsync(string key, string filename, Func<CancellationToken, Task<T>> factory, CancellationToken ct = null) | Retrieves an item from the cache cast to type of T, or inserts using the provided Factory function and file dependency |
int GetVersion() | Returns the major version for Microsoft.Extensions.Caching.Memory |
void Insert(string key, object item, TimeSpan expiration, bool sliding = null, long size = null) | Inserts item into Cache with time based expiration |
void Insert(string key, object item, long size = null) | Inserts item into the Cache using default expirations |
void Insert(string key, object item, string filename, long size = null) | Insert item into the Cache using a file dependency |
object Remove(string key) | Removes a Cached item |
bool TryGetValue(string key, out T output) | Attempts to retrieves an item from cache cast to type of T |
bool TryGetValue(string key, out object output) | Attempts to retrieves an item from cache |