Class CachedResponse
- Namespace
- TcgDex.Caching
- Assembly
- TcgDex.CSharpSdk.dll
A cached HTTP response body together with the validator needed to refresh it.
public sealed record CachedResponse : IEquatable<CachedResponse>Inheritance
Implements
Inherited Members
Remarks
The body is stored as bytes rather than as a deserialized model, so one cached entry serves every caller regardless of the type they deserialize into, and nothing mutable is ever shared between them.
Properties
Body
The raw response body.
public required byte[] Body { get; init; }Property Value
- byte[]
ContentType
The Content-Type to replay, so cached responses parse identically.
public string? ContentType { get; init; }Property Value
ETag
The ETag the API returned, used to revalidate once the entry is no
longer fresh.
public string? ETag { get; init; }Property Value
Remarks
Without this a stale entry costs a full re-download. With it, an unchanged
resource costs a 304 and zero bytes of body.
StoredAt
When the entry was stored or last revalidated.
public required DateTimeOffset StoredAt { get; init; }Property Value
Methods
IsFresh(DateTimeOffset, TimeSpan)
Whether the entry is still within timeToLive of now.
public bool IsFresh(DateTimeOffset now, TimeSpan timeToLive)Parameters
nowDateTimeOffset-
The current time.
timeToLiveTimeSpan-
How long an entry may be served without revalidation.