ApiCache class

Two-level cache for GET responses.

  • L1 (memory): instant reads, cleared on app restart.
  • L2 (Hive): persistent across restarts, slower than memory.

On read: L1 first → L2 fallback → miss. On write: both levels updated simultaneously. On invalidation: both levels cleared.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

clearAll() Future<void>
Clear everything — both L1 and L2.
init() Future<void>
Internal — called by Server.init.
invalidate(String key) Future<void>
Remove a single cache entry by exact key.
invalidateWhere(String pattern) Future<void>
Remove all entries whose key contains pattern. Useful for invalidating a whole endpoint family e.g. /v1/brands.
read(String key) → dynamic
Returns cached data for key or null on miss/expiry.
write(String key, dynamic data, Duration ttl) Future<void>
Store data under key with the given ttl.