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();
The update
method will update a lock if it has expired, matches the given key
and matches the given owner
.
Returns number of updated rows or documents.
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"