Interface ITcgDexResponseCache
- Namespace
- TcgDex.Caching
- Assembly
- TcgDex.CSharpSdk.dll
Stores API responses so repeated reads avoid the network.
public interface ITcgDexResponseCacheRemarks
Implement this to back the cache with something shared or persistent — Redis, a distributed cache, or disk. The default is in-memory and per-process. Implementations must be safe for concurrent use.
Methods
GetAsync(string, CancellationToken)
Retrieves an entry, or null if absent.
ValueTask<CachedResponse?> GetAsync(string key, CancellationToken cancellationToken = default)Parameters
keystring-
The cache key, derived from the request URI.
cancellationTokenCancellationToken-
Cancels the lookup.
Returns
- ValueTask<CachedResponse?>
-
The cached response, or null.
RemoveAsync(string, CancellationToken)
Removes an entry, if present.
ValueTask RemoveAsync(string key, CancellationToken cancellationToken = default)Parameters
keystring-
The cache key.
cancellationTokenCancellationToken-
Cancels the removal.
Returns
- ValueTask
-
A task that completes when the entry is gone.
SetAsync(string, CachedResponse, TimeSpan, CancellationToken)
Stores an entry.
ValueTask SetAsync(string key, CachedResponse response, TimeSpan timeToLive, CancellationToken cancellationToken = default)Parameters
keystring-
The cache key.
responseCachedResponse-
The response to store.
timeToLiveTimeSpan-
How long it may be served before revalidation.
cancellationTokenCancellationToken-
Cancels the write.
Returns
- ValueTask
-
A task that completes when the entry is stored.