Skip to content

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 IVitreousCache

Attempts to retrieve a value from the cache.

ValueTask<(bool Hit, T? Value)> GetAsync<T>(string key, CancellationToken ct = default)

key string

ct CancellationToken

ValueTask<(bool Hit, T? Value)>

(true, value) on a hit; (false, default) on a miss or deserialisation error.

T

Removes a single cache entry by exact key.

ValueTask RemoveAsync(string key, CancellationToken ct = default)

key string

ct CancellationToken

ValueTask

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)

tag string

ct CancellationToken

ValueTask

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)

key string

value T

tags IReadOnlyList<string>

options DistributedCacheEntryOptions

ct CancellationToken

ValueTask

T