CacheEntry class

A stored cache entry.

Carries validators alongside the payload so conditional requests (If-None-Match / If-Modified-Since) can revalidate cheaply.

Constructors

CacheEntry({required dynamic data, required DateTime storedAt, String? etag, String? lastModified, Duration? maxAge, int statusCode = 200})
const

Properties

canRevalidate → bool
Whether this entry carries a validator usable for a conditional request.
no setter
conditionalHeaders → Map<String, String>
Conditional request headers derived from this entry's validators.
no setter
data → dynamic
The cached response body.
final
etag → String?
ETag header from the response that produced this entry, if any.
final
hashCode → int
The hash code for this object.
no setterinherited
lastModified → String?
Last-Modified header from the response that produced this entry.
final
maxAge → Duration?
Server-declared lifetime, from Cache-Control: max-age.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
statusCode → int
Status code of the response that produced this entry.
final
storedAt → DateTime
When the entry was written.
final

Methods

ageAt(DateTime now) → Duration
Age of this entry relative to now.
isFresh(Duration fallback, {DateTime? now}) → bool
Whether the entry is still fresh given a client-side fallback lifetime.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refreshed({DateTime? at, Duration? maxAge}) → CacheEntry
Copy with a refreshed storedAt, used after a 304 revalidation.
toJson() → Map<String, dynamic>
Serialize for storage.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

fromJson(dynamic raw) → CacheEntry?
Deserialize an entry previously produced by toJson.