DefaultCache class

Default implementation of the Cache interface

Inheritance

Constructors

DefaultCache(CacheStore storage, {String? name, ExpiryPolicy? expiryPolicy, KeySampler? sampler, EvictionPolicy? evictionPolicy, int? maxEntries, CacheLoader? cacheLoader, Clock? clock, EventListenerMode? eventListenerMode})
Builds a DefaultCache out of a mandatory CacheStore and a set of optional configurations

Properties

cacheLoader CacheLoader
The CacheLoader for this cache. When set is used when the cache is expired to fetch a new value
final
clock → Clock
The source of time to be used on this cache
final
eventPublishingMode EventListenerMode
The event publishing mode of this cache
final
evictionPolicy EvictionPolicy
The EvictionPolicy used by this cache
final
expiryPolicy ExpiryPolicy
The ExpiryPolicy for this cache
final
hashCode int
The hash code for this object.
no setterinherited
keys Future<Iterable<String>>
Returns a Iterable over all the Cache keys
no setteroverride
maxEntries int
The maximum number of entries supported by this cache
final
name String
The name of this cache
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sampler KeySampler
The KeySampler used this cache upon eviction
final
size Future<int>
The number of entries on the cache
no setteroverride
storage CacheStore
The CacheStore for this cache
final
streamController StreamController
The StreamController for this cache events
final

Methods

clear() Future<void>
Clears the contents of the cache
override
containsKey(String key) Future<bool>
Determines if the Cache contains an entry for the specified key.
override
get(String key, {Duration? expiryDuration}) Future
Returns the cache value for the specified key. If specified expiryDuration is used instead of the configured expiry policy duration
override
getAndPut(String key, dynamic value, {Duration? expiryDuration}) Future
Associates the specified value with the specified key in this cache, returning an existing value if one existed. If the cache previously contained a mapping for the key, the old value is replaced by the specified value
override
getAndRemove(String key) Future
Removes the entry for a key only if currently mapped to some value.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on<T extends CacheEvent>() Stream<T>
Listens for events of Type T and its subtypes.
override
put(String key, dynamic value, {Duration? expiryDuration}) Future<void>
Add / Replace the cache value for the specified key. If specified expiryDuration is used instead of the configured expiry policy duration
override
putIfAbsent(String key, dynamic value, {Duration? expiryDuration}) Future<bool>
Associates the specified key with the given value if not already associated with a value.
override
remove(String key) Future<void>
Removes the mapping for a key from this cache if it is present.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String key) Future
Get the cache value for the specified key.
override