CacheEntry<T> class
An entry in the query cache.
Holds the current QoraState and manages a reactive broadcast stream so that all active subscribers instantly receive every state transition — whether triggered by a fetch, QoraClient.setQueryData, or an invalidation.
Each entry also tracks subscriber count and expiry timers, enabling automatic garbage collection when no one is watching.
Constructors
-
CacheEntry({required QoraState<
T> state, DateTime? createdAt})
Properties
- createdAt → DateTime
-
When this entry was first inserted into the cache.
final
- gcTimer ↔ Timer?
-
Garbage-collection timer, scheduled after the last subscriber
unsubscribes and QoraOptions.gcTime has elapsed.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
invalidations
→ Stream<
void> -
Emits an event each time invalidate is called.
no setter
- isActive → bool
-
Whether this entry currently has at least one active stream subscriber.
no setter
- isDisposed → bool
-
Whether this entry has been disposed.
no setter
- lastAccessedAt ↔ DateTime
-
When this entry was last accessed (read or written).
getter/setter pair
- lastOptions ↔ QoraOptions?
-
The QoraOptions used on the most recent fetch.
getter/setter pair
- refetchTimer ↔ Timer?
-
Periodic refetch timer, set by QoraClient.watchQuery when
QoraOptions.refetchInterval is configured.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
→ QoraState<
T> -
The current query state.
no setter
-
stream
→ Stream<
QoraState< T> > -
A stream that immediately replays the current state to new subscribers,
then forwards all future updateState calls.
no setter
- subscriberCount → int
-
Number of active stream subscribers.
no setter
Methods
-
addSubscriber(
) → void - Increment subscriber count and refresh lastAccessedAt.
-
dispose(
) → void - Release all resources held by this entry.
-
invalidate(
) → void -
Mark this entry as stale by transitioning to Loading with the
current data as
previousData, or Initial if there is no current data. -
isStale(
Duration? staleTime) → bool -
Returns
trueif the cached data is older thanstaleTime. -
markStale(
) → void - Mark this entry as stale without pushing any state update to observers.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeSubscriber(
) → void - Decrement subscriber count.
-
setError(
Object error) → void -
Force this entry into Failure state, preserving any
previousData. -
shouldEvict(
Duration gcTime) → bool -
Returns
truewhen the entry has been idle (no access) longer thangcTimeand is safe to garbage-collect. -
toString(
) → String -
A string representation of this object.
inherited
-
touch(
) → void - Refresh lastAccessedAt to prevent premature eviction.
-
updateState(
QoraState< T> newState) → void -
Push
newStateto all active subscribers and update internal state.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited