ZenQueryCache class

Global cache manager for ZenQuery instances

Supports both global queries and scope-aware queries for flexible lifecycle management and cache isolation.

Handles:

  • Query deduplication
  • Cache invalidation
  • Memory management
  • Query coordination

Properties

hashCode int
The hash code for this object.
no setterinherited
queries List<ZenQuery>
Get all queries
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Clear all queries and cache
clearScope(String scopeId) → void
Clear all queries in a specific scope
configureForTesting({bool useRealTimers = false}) → void
Configure timer behavior for testing
deduplicateFetch<T>(String queryKey, Future<T> fetcher()) Future<T>
Deduplicate concurrent fetches for the same query
getCachedData<T>(Object queryKey) → T?
Get cached data for a query
getQuery<T>(Object queryKey) ZenQuery<T>?
Get query by key
getScopeQueries(String scopeId) List<ZenQuery>
Get all queries in a specific scope
getScopeStats(String scopeId) Map<String, dynamic>
Get statistics about scope queries
getStats() Map<String, dynamic>
Get comprehensive cache statistics
invalidateQueries(bool predicate(String key)) → void
Invalidate queries matching pattern
invalidateQueriesWithPrefix(String prefix) → void
Invalidate all queries with a prefix
invalidateQuery(Object queryKey) → void
Invalidate query (mark as stale)
invalidateScope(String scopeId) → void
Invalidate all queries in a specific scope
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prefetch<T>({required Object queryKey, required Future<T> fetcher(), Duration? staleTime, Duration? cacheTime}) Future<void>
Prefetch data and store it in the cache if it's not already fresh.
refetchQueries(bool predicate(String key)) Future<void>
Refetch queries matching pattern
refetchQuery(String queryKey) Future<void>
Refetch query by key
refetchScope(String scopeId) Future<void>
Refetch all queries in a specific scope
register<T>(ZenQuery<T> query) → void
Register a query in the cache
registerScoped<T>(ZenQuery<T> query, String scopedKey, String scopeId) → void
Register a scoped query with automatic scope tracking
removeQuery(Object queryKey) → void
Remove query from cache
toString() String
A string representation of this object.
inherited
unregister(String queryKey) → void
Unregister a query from the cache
updateCache<T>(String queryKey, T data, DateTime timestamp) → void
Update cache for a query

Operators

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

Static Properties

instance ZenQueryCache
final