MemoryDistributedCache class

An implementation of IDistributedCache using an in-memory cache.

This is useful for testing distributed cache code without requiring an actual distributed cache implementation, or for single-server applications that want to use the IDistributedCache interface.

Implemented types
Available extensions

Constructors

MemoryDistributedCache([MemoryCacheOptions? options])
Creates a new instance of MemoryDistributedCache.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Disposes the underlying memory cache.
get(String key) Future<Uint8List?>
Gets a value with the given key.
override
getString(String key) Future<String?>

Available on IDistributedCache, provided by the DistributedCacheExtensions extension

Gets a string value from the cache with the given key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refresh(String key) Future<void>
Refreshes a value in the cache based on its key, resetting its sliding expiration timeout (if any).
override
remove(String key) Future<void>
Removes the value with the given key.
override
set(String key, Uint8List value, [DistributedCacheEntryOptions? options]) Future<void>
Sets a value with the given key.
override
setBytes(String key, Uint8List value) Future<void>

Available on IDistributedCache, provided by the DistributedCacheExtensions extension

Sets the value for key without options.
setString(String key, String value, [DistributedCacheEntryOptions? options]) Future<void>

Available on IDistributedCache, provided by the DistributedCacheExtensions extension

Sets a string value in the cache with the given key.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited