To utilize the RedisLockAdapter, you must install the "ioredis" package.
RedisLockAdapter
"ioredis"
Note in order to use RedisLockAdapter correctly, ensure you use a single, consistent database across all server instances.
IMPORT_PATH: "@daiso-tech/core/lock/adapters"
"@daiso-tech/core/lock/adapters"
import { RedisLockAdapter } from "@daiso-tech/core/lock/adapters";import Redis from "ioredis";const database = new Redis("YOUR_REDIS_CONNECTION_STRING");const lockAdapter = new RedisLockAdapter(database); Copy
import { RedisLockAdapter } from "@daiso-tech/core/lock/adapters";import Redis from "ioredis";const database = new Redis("YOUR_REDIS_CONNECTION_STRING");const lockAdapter = new RedisLockAdapter(database);
The acquire method acquires a lock only if expired.
acquire
Returns true if expired otherwise false is returned.
true
false
The forceRelease method releases a lock regardless of the owner.
forceRelease
Returns true if the lock exists or false if the lock is expired.
The refresh method will upadte ttl of lock if it matches the owner and is expireable.
refresh
ttl
owner
Returns false if the lock is unexpireable, the is expired, does not match the owner otherwise true is returned.
The release method releases a lock if the owner matches.
release
Returns true if released otherwise false is returned.
To utilize the
RedisLockAdapter
, you must install the"ioredis"
package.Note in order to use
RedisLockAdapter
correctly, ensure you use a single, consistent database across all server instances.IMPORT_PATH:
"@daiso-tech/core/lock/adapters"