Cache<K, V> class
abstract
An asynchronous, loading cache interface.
- Mixed-in types
- Implementers
Constructors
- Cache()
-
Unnamed default constructor.
const
-
Cache.empty({required Loader<
K, V> loader}) -
Creates an empty or null cache, useful mostly for testing.
factory
-
Cache.expiry({required Loader<
K, V> loader, Duration? updateExpiry, Duration? accessExpiry}) -
Creates an expiry cache.
factory
-
Cache.fifo({required Loader<
K, V> loader, int maximumSize = 100}) -
Creates a First-in/First-out (FIFO) cache.
factory
-
Cache.lru({required Loader<
K, V> loader, int maximumSize = 100}) -
Creates a Least Recently Used (LRU) cache.
factory
Properties
- defaultToStringPrinter → ObjectPrinter
-
Override to configure the empty ObjectPrinter.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- toStringPrinter → ObjectPrinter
-
Override and call super to add values to the ObjectPrinter.
no setterinherited
Methods
-
get(
K key) → Future< V> -
Returns the value associated with the
key. -
getAll(
Iterable< K> keys) → Future<Map< K, V> > -
Returns a map of the values associated with the
keys. -
getIfPresent(
K key) → Future< V?> -
Returns the value associated with the
key, otherwisenull. -
invalidate(
K key) → Future< void> -
Discards any cached value with the
key. -
invalidateAll(
[Iterable< K> ? keys]) → Future<void> -
Discards all cached values, or only the values associated with
keysif specified. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
putAll(
Map< K, FutureOr< values) → Future<V> >void> - Alias for setAll to store all key-value entries.
-
reap(
) → Future< int> - Returns the number of reaped items.
-
set(
K key, FutureOr< V> value) → Future<V> -
Stores the
valueassociated with thekey. -
setAll(
Map< K, FutureOr< values) → Future<V> >void> -
Stores all the
valuesin this cache. -
size(
) → Future< int> - Returns the number of currently cached values.
-
toString(
) → String -
Standard Object.toString implementation. Do not override, instead
implement toStringPrinter to customize.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited