import { KyselyLockAdapter } from "@daiso-tech/core/lock/adapters";
import Sqlite from "better-sqlite3";
const lockAdapter = new KyselyLockAdapter({
kysely: new Kysely({
dialect: new SqliteDialect({
database: new Sqlite("local.db"),
}),
}),
});
// You need initialize the adapter once before using it.
await lockAdapter.init();
Removes a lock from the database regardless of its owner.
The unique identifier for the lock to remove.
Removes a lock from the database only if it is currently held by the specified owner.
The unique identifier for the lock.
Returns ILockExpirationData | null
. The ILockExpirationData
data if successfully removed, otherwise null
if the lock wasn't found or the owner didn't match.
Updates the expiration date of a lock if it is currently held by the specified owner.
The unique identifier for the lock.
The new date and time when the lock should expire.
Returns a number greater than or equal to 1
if the lock's expiration was updated, or 0
if the lock wasn't found or the owner didn't match.
To utilize the
KyselyLockAdapter
, you must install the"kysely"
package and configure aKysely
class instance.Note in order to use
KyselyLockAdapter
correctly, ensure you use a single, consistent database across all server instances. The adapter have been tested withsqlite
,postgres
andmysql
databases.IMPORT_PATH:
"@daiso-tech/core/lock/adapters"