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:

Implementers
Available Extensions

Constructors

CachedValue(ComputeCacheCallback<CacheContentType> callback)
Creates a CachedValue that is only manually invalidated.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isValid bool
Check the current state of the cache.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → CacheContentType
Access the current cache value.
no setter

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.