import { MongodbLockAdapter } from "@daiso-tech/core/lock/adapters";
import { MongoClient } from "mongodb";
const client = await MongoClient.connect("YOUR_MONGODB_CONNECTION_STRING");
const database = client.db("database");
const lockAdapter = new MongodbLockAdapter({
database
});
// You need initialize the adapter once before using it.
await lockAdapter.init()
The refresh
method will upadte ttl
of lock if it matches the owner
and is expireable.
Returns false
if the lock is unexpireable, the is expired, does not match the owner
otherwise true
is returned.
To utilize the
MongodbLockAdapter
, you must install the"mongodb"
package.Note in order to use
MongodbLockAdapter
correctly, ensure you use a single, consistent database across all server instances.IMPORT_PATH:
"@daiso-tech/core/lock/adapters"