RedisCache class Null safety
Distributed cache that stores values in Redis in-memory database.
Configuration parameters
connection(s)
:discovery_key
: (optional) a key to retrieve the connection from IDiscoveryhost
: host name or IP addressport
: port numberuri
: resource URI or connection string with all parameters in itcredential(s)
:store_key
: key to retrieve parameters from credential storeusername
: user name (currently is not used)password
: user passwordoptions
:retries
: number of retries (default: 3)timeout
: default caching timeout in milliseconds (default: 1 minute)max_size
: maximum number of values stored in this cache (default: 1000)
References
- :discovery::*:1.0 (optional) IDiscovery services to resolve connection
- :credential-store::*:1.0 (optional) Credential stores to resolve credential ICredentialStore
Example
var cache = RedisCache();
cache.configure(ConfigParams.fromTuples([
"host", "localhost",
"port", 6379
]));
await cache.open("123");
...
await cache.store("123", "key1", "ABC");
var value = await cache.retrieve("123", "key1");
// Result: "ABC"
- Implemented types
Constructors
- RedisCache()
- Creates a new instance of this 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
-
close(
String? correlationId) → Future -
Closes component and frees used resources. [...]
override
-
configure(
ConfigParams config) → void -
Configures component by passing configuration parameters. [...]
override
-
isOpen(
) → bool -
Checks if the component is opened. [...]
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
open(
String? correlationId) → Future -
Opens the component. [...]
override
-
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
-
setReferences(
IReferences references) → void -
Sets references to dependent components. [...]
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