GenericCache<T> class
Generic implementation of the Cache interface
- Implemented types
-
- Cache<
T>
- Cache<
- Available extensions
Constructors
-
GenericCache(Store<
CacheInfo, CacheEntry> storage, {CacheManager? manager, String? name, ExpiryPolicy? expiryPolicy, KeySampler? sampler, EvictionPolicy? evictionPolicy, int? maxEntries, CacheLoader<T> ? cacheLoader, Clock? clock, EventListenerMode? eventListenerMode, bool? statsEnabled, CacheStats? stats}) - Builds a GenericCache out of a mandatory Store and a set of optional configurations
Properties
-
cacheLoader
→ CacheLoader<
T?> -
The CacheLoader for this cache. When set it's used whenever
a get by key returns null (absent or expired)
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 Stash keysno setteroverride - manager → CacheManager?
-
Gets the CacheManager that owns and manages the Cache.
Returns the manager or
null
if the Cache is not managedfinal - 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 stash
no setteroverride
- stats → CacheStats
-
final
- statsEnabled → bool
-
final
-
storage
→ Store<
CacheInfo, CacheEntry> -
The Store for this cache
final
- streamController → StreamController
-
The StreamController for this cache events
final
Methods
-
clear(
) → Future< void> -
Clears the contents of the stash
override
-
close(
) → Future< void> -
Closes the stash
override
-
containsKey(
String key) → Future< bool> -
Determines if the Stash contains an entry for the specified
key
.override -
get(
String key, {CacheEntryDelegate< T> ? delegate}) → Future<T?> -
Returns the cache value for the specified
key
.override -
getAndPut(
String key, T value, {CacheEntryDelegate< T> ? delegate}) → Future<T?> -
Associates the specified
value
with the specifiedkey
in this cache, returning an existing value if one existed. If the cache previously contained a mapping for thekey
, the old value is replaced by the specified value.override -
getAndRemove(
String key) → Future< T?> -
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<
E extends CacheEvent< (T> >) → Stream< E> -
Listens for events of Type
T
and its subtypes.override -
put(
String key, T value, {CacheEntryDelegate< T> ? delegate}) → Future<void> -
Add / Replace the cache
value
for the specifiedkey
.override -
putIfAbsent(
String key, T value, {CacheEntryDelegate< T> ? delegate}) → Future<bool> -
Associates the specified
key
with the givenvalue
if not already associated with a value.override -
remove(
String key) → Future< void> -
Removes the value stored under a key from this stash if present.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String key) → Future< T?> -
Get the stash value for the specified
key
.override