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
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
keyshare 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
keyif available and unexpired. -
getQueryData<
T> (List key) → T? -
Retrieves cached query data for
keyif available and unexpired, or returnsnull. -
invalidateQueries(
List keyPrefix) → void -
Invalidates all cached queries matching
keyPrefix. -
markStale(
List keyPrefix) → void -
Marks queries matching
keyPrefixas stale without triggering immediate refetch. -
matchesKey(
List candidateKey, List prefix) → bool -
Checks whether a
candidateKeymatches a givenprefixkey 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
entryin 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
keyusing anupdatertransformation 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.