IVitreousCache interface
Namespace: Vitreous.Caching.Abstractions
Assembly: Vitreous.Caching.dll
Abstraction over the underlying cache store.
Register the default implementation (DistributedVitreousCache) for
IDistributedCache-backed caching, or the Redis implementation
(RedisVitreousCache from Vitreous.Caching.Redis) for full
tag-based invalidation support.
public interface IVitreousCacheMethods
Section titled “Methods”GetAsync<T>(string, CancellationToken)
Section titled “ GetAsync<T>(string, CancellationToken)”Attempts to retrieve a value from the cache.
ValueTask<(bool Hit, T? Value)> GetAsync<T>(string key, CancellationToken ct = default)Parameters
Section titled “Parameters”key string
Returns
Section titled “Returns”ValueTask<(bool Hit, T? Value)>
(true, value) on a hit; (false, default) on a miss or deserialisation error.
Type Parameters
Section titled “Type Parameters”T
RemoveAsync(string, CancellationToken)
Section titled “ RemoveAsync(string, CancellationToken)”Removes a single cache entry by exact key.
ValueTask RemoveAsync(string key, CancellationToken ct = default)Parameters
Section titled “Parameters”key string
Returns
Section titled “Returns”RemoveByTagAsync(string, CancellationToken)
Section titled “ RemoveByTagAsync(string, CancellationToken)”Removes all cache entries associated with tag.
This is a no-op in the base IDistributedCache implementation;
only the Redis backend provides actual tag removal.
ValueTask RemoveByTagAsync(string tag, CancellationToken ct = default)Parameters
Section titled “Parameters”tag string
Returns
Section titled “Returns”SetAsync<T>(string, T, IReadOnlyList<string>, DistributedCacheEntryOptions, CancellationToken)
Section titled “ SetAsync<T>(string, T, IReadOnlyList<string>, DistributedCacheEntryOptions, CancellationToken)”Stores a value in the cache under key, associated with
tags (used by the Redis backend for bulk invalidation).
ValueTask SetAsync<T>(string key, T value, IReadOnlyList<string> tags, DistributedCacheEntryOptions options, CancellationToken ct = default)Parameters
Section titled “Parameters”key string
value T
tags IReadOnlyList<string>
options DistributedCacheEntryOptions
Returns
Section titled “Returns”Type Parameters
Section titled “Type Parameters”T