ApiCache class

Global cache management facade.

Use this to invalidate entries or replace the storage backend.

// Replace with persistent storage once at startup
ApiCache.storage = HiveCacheStorage();

// Invalidate a single entry
await ApiCache.invalidate('user_galleries');

// Invalidate by prefix pattern
await ApiCache.invalidatePattern('gallery_');

// Wipe everything
await ApiCache.clear();

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 Properties

storage CacheStorage
Active storage backend. Defaults to InMemoryCacheStorage. Replace early in app startup to persist across restarts.
getter/setter pair

Static Methods

clear() Future<void>
Clear the entire cache.
get(String key) Future
Retrieve and decode data for key, or null if missing/expired.
invalidate(String key) Future<void>
Delete a single cache entry.
invalidatePattern(String prefix) Future<void>
Delete all entries whose keys start with prefix.
set(String key, dynamic data, Duration ttl) Future<void>
Store serialised data under key.