GcTime class sealed Option values
How long a query nobody observes stays in the cache — the gcTime
option (the name is TanStack Query's: "garbage-collection time").
When a query's last observer leaves, a timer of this length starts; if no observer comes back before it fires, the query and its data are removed from the cache. The same option on a mutation governs how long a settled mutation stays in the mutation cache. When several observers of one query ask for different times, the longest wins (GcTime.longest).
Default: GcTime.defaultValue, five minutes.
gcTime: GcTime.defaultValue // 5 minutes
gcTime: const GcTime.duration(Duration(seconds: 30))
gcTime: const GcTime.duration(Duration.zero) // drop as soon as unused
gcTime: GcTime.never // keep until removed or the client clears
- Implementers
- Annotations
-
- @immutable
Constructors
- GcTime.duration(Duration duration)
-
Removed from the cache
durationafter the last observer leaves (TanStack Query:gcTime: ms).constfactory
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 Methods
-
longest(
GcTime? a, GcTime? b) → GcTime? -
The longer of
aandb, with GcTime.never winning outright; anull(unset) loses to anything. This is how several observers asking for different times are reconciled, as in TanStack Query.
Constants
- defaultValue → const GcTime
- The default: five minutes, the same as TanStack Query's.
- never → const GcTime
-
Never collected: stays until removed by hand or the client is cleared
(TanStack Query:
gcTime: Infinity).