CachedComputation<R, T, K> class
Caches a value that can be computed.
The cache keys are compared deeply (see isEqualsDeep and
deepHashCode), so List and Map keys hit the cache when they have
equal contents. null results are cached too.
Constructors
- CachedComputation(R function(T), [K keyGenerator(T)?])
Properties
- cacheSize → int
-
no setter
- computationCount → int
-
no setter
- function → R Function(T)
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyGenerator → K? Function(T)
-
Generates the cache key of a value. The default one is a deep copy of
the value (see deepCopy), so changing a value after the computation
doesn't change its cached key. Limit: a map whose types deepCopy can't
reproduce isn't copied, so it must not be changed after the computation
(or use a custom key generator).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → void - Clears cache.
-
compute(
T value) → R - Computes and caches value.
-
generateKey(
T value) → K? -
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