ComputeOnceCache<K extends Object, V> class
Caches TimedComputeOnce instances by key, ensuring each computation is executed only once while retained.
After resolution, entries are kept for retentionDuration. When the duration is zero, entries are removed immediately.
Constructors
- ComputeOnceCache({Duration retentionDuration = Duration.zero})
-
Creates a cache with an optional
retentionDuration.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- retentionDuration → Duration
-
How long a resolved computation is kept in the cache.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
calls(
) → Map< K, TimedComputeOnce< V> > - Returns a snapshot of current cached computations.
-
clear(
) → void - Clears the cache and cancels all retention timers.
-
get(
K key, ComputeCall< V> call, {PosComputeCall<V> ? posCompute, bool resolve = true}) → TimedComputeOnce<V> -
Returns an existing TimedComputeOnce for
keyor creates a new one. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
K key) → TimedComputeOnce< V> ? - Removes a cached computation and cancels any associated timer.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited