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 = new 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. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

configure(ConfigParams config) → void
Configures component by passing configuration parameters. [...]
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
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited