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;
As an abstract class main constructor returns a SimpleCachedValue that creates a cache that can only be marked as invalid or refresh manually.
To add automatic rules on invalidating and refreshing of a cache, see:
- DependentCachedValue creates a cache that is updated if a dependency changes.
- TimeToLiveCachedValue creates a cache that is invalidated after some given Duration.
- Implementers
- Available Extensions
Constructors
-
CachedValue(ComputeCacheCallback<
CacheContentType> callback) -
Creates a CachedValue that is only manually invalidated.
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}) → DependentCachedValue<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.