CachedValue<CacheContentType> class
abstract
A value container that caches values resultant from a potentially expensive operation.
It is convenient for storing values that:
- Are computed from other values;
- Can be changed given known and unknown conditions;
- Should not be computed on every access;
See also:
- CachedValue.simple that creates a cache updated manually
- CachedValue.dependent that creates a cache that is updated if a dependency changes.
Constructors
-
CachedValue(ComputeCacheCallback<
CacheContentType> callback) -
A shorthand to CachedValue.simple.
factory
Properties
Methods
-
invalidate(
) → void - Marks the cache as invalid.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → CacheContentType - Updates the cache to an updated state.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
dependent<
A, B> ({required ComputeCacheDependency< B> on, required ComputeCacheCallback<A> compute}) → ComputedCachedValue<A, B> - Creates a CachedValue that its validity is defined by a dependency.
-
simple<
CacheContentType> (ComputeCacheCallback< CacheContentType> callback) → SimpleCachedValue<CacheContentType> - Creates a CachedValue that is only manually invalidated. The main CachedValue constructor is a shorthand for this method.