BloomData class

Global query cache manager for Bloom Data with automated periodic TTL garbage collection and request deduplication.

Provides in-memory caching, stale-while-revalidate invalidation cascades, and concurrent in-flight request deduplication across widget subtrees.

Example:

BloomData.setQueryData(['user', 42], (_) => {'name': 'Alice'});
final user = BloomData.getQueryData<Map<String, dynamic>>(['user', 42]);
BloomData.invalidateQueries(['user']);

Constructors

BloomData()

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

entryCount int
Total count of cached query entries currently in memory.
no setter

Static Methods

clear() → void
Clears all query cache entries, cancels pending requests, and resets listeners.
deduplicate<T>(List key, Future<T> fetcher()) Future<T>
Request deduplication: ensures multiple concurrent fetches for the same key share a single Future.
dumpCache() List<Map<String, dynamic>>
Returns a snapshot summary of all active cache entries for DevTools visual inspection.
garbageCollect() int
Removes all expired entries from cache memory to reclaim resources.
getEntry<T>(List key) QueryCacheEntry<T>?
Retrieves a full cached QueryCacheEntry for key if available and unexpired.
getQueryData<T>(List key) → T?
Retrieves cached query data for key if available and unexpired, or returns null.
invalidateQueries(List keyPrefix) → void
Invalidates all cached queries matching keyPrefix.
markStale(List keyPrefix) → void
Marks queries matching keyPrefix as stale without triggering immediate refetch.
matchesKey(List candidateKey, List prefix) bool
Checks whether a candidateKey matches a given prefix key list.
normalizeKey(List key) String
Converts a key list (e.g. ['users', 42, 'posts']) into a deterministic normalized string key.
onInvalidated(List key) Stream<void>
Listens for invalidation events broadcast on a specific query key.
putEntry<T>(QueryCacheEntry<T> entry) → void
Stores or updates a raw cache entry in memory.
refreshStaleQueries() → void
Refreshes all currently stale cached queries across the application.
releaseListener(List key) → void
Releases a listener slot previously acquired via onInvalidated.
removeEntry(List key) → void
Removes a specific query cache entry by key.
setQueryData<T>(List key, T? updater(T? oldData)) → void
Sets cache data directly for a given key using an updater transformation function.
startGarbageCollector({Duration interval = const Duration(minutes: 5)}) → void
Starts automated periodic garbage collection running every interval (defaults to 5 minutes).
stopGarbageCollector() → void
Stops automated periodic garbage collection.