MemoryCache class

Cache that stores values in the process memory.

Remember: This implementation is not suitable for synchronization of distributed processes.

Configuration parameters

options:

  • timeout: default caching timeout in milliseconds (default: 1 minute)
  • max_size: maximum number of values stored in this cache (default: 1000)

See ICache

Example

var cache = MemoryCache();

await cache.store('123', 'key1', 'ABC')
var value await cache.retrive('123', 'key1')
        // Result: 'ABC'
Implemented types

Constructors

MemoryCache()
Creates a new instance of the cache.

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

configure(ConfigParams config) → void
Configures component by passing configuration parameters.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String? correlationId, String? key) Future
Removes a value from the cache by its key.
override
retrieve(String? correlationId, String? key) Future
Retrieves cached value from the cache using its key. If value is missing in the cache or expired it returns null.
override
store(String? correlationId, String? key, dynamic value, int? timeout) Future
Stores value in the cache with expiration time.
override
toString() String
A string representation of this object.
inherited

Operators

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