RedisLock class Null safety

Distributed lock that is implemented based on Redis in-memory database.

Configuration parameters

  • connection(s):
  • discovery_key: (optional) a key to retrieve the connection from IDiscovery
  • host: host name or IP address
  • port: port number
  • uri: resource URI or connection string with all parameters in it
  • credential(s):
  • store_key: key to retrieve parameters from credential store
  • username: user name (currently is not used)
  • password: user password
  • options:
  • retry_timeout: timeout in milliseconds to retry lock acquisition. (Default: 100)
  • retries: number of retries (default: 3)

References

  • :discovery::*:1.0 (optional) IDiscovery services to resolve connection
  • :credential-store::*:1.0 (optional) Credential stores to resolve credential ICredentialStore

Example

   var lock = RedisLock();
   lock.configure(ConfigParams.fromTuples([
     'host', 'localhost',
     'port', 6379
   ]));

   await lock.open('123');
     ...

   await lock.acquire('123', 'key1');

   try {
       // Processing...
   } finally {
      await lock.releaseLock('123', 'key1');
       // Continue...
   }
Inheritance
Implemented types

Constructors

RedisLock()

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

acquireLock(String? correlationId, String key, int ttl, int timeout) Future
Makes multiple attempts to acquire a lock by its key within give time interval.
inherited
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
releaseLock(String? correlationId, String key) Future
Releases prevously acquired lock by its key.
override
setReferences(IReferences references) → void
Sets references to dependent components.
override
toString() String
A string representation of this object.
inherited
tryAcquireLock(String? correlationId, String key, int ttl) Future<bool>
Makes a single attempt to acquire a lock by its key. It returns immediately a positive or negative result.
override

Operators

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