Note the MemoryLockAdapter is limited to single process usage and cannot be shared across multiple servers or different processes. This adapter is meant to be used for testing.
MemoryLockAdapter
IMPORT_PATH: "@daiso-tech/core/lock/adapters"
"@daiso-tech/core/lock/adapters"
import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";const lockAdapter = new MemoryLockAdapter(); Copy
import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";const lockAdapter = new MemoryLockAdapter();
You can also provide an Map.
Map
import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";const map = new Map<any, any>();const lockAdapter = new MemoryLockAdapter(map); Copy
import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";const map = new Map<any, any>();const lockAdapter = new MemoryLockAdapter(map);
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.
Note the
MemoryLockAdapter
is limited to single process usage and cannot be shared across multiple servers or different processes. This adapter is meant to be used for testing.IMPORT_PATH:
"@daiso-tech/core/lock/adapters"