To utilize the SqliteLockAdapter, you must install the "better-sqlite3" and "@types/better-sqlite3" packages.
Note the SqliteLockAdapter is limited to single server usage and cannot be shared across multiple servers but it can be shared between different processes.
To use it correctly, ensure all process instances access the same consistent, persisted database.
Creates the table where the cache values are stored and it's related indexes.
Note the init method needs to be called before using the adapter.
Returns Promise<void>
insert
insert(key, owner, expiration): Promise<void>
The insert method will create a lock if one does not already exist.
Parameters
key: string
owner: string
expiration: null | Date
Returns Promise<void>
refresh
refresh(key, owner, expiration): Promise<number>
The refresh method will upadte expiration of lock if it matches the given key and matches the given owner.
Returns number of updated rows or documents.
Parameters
key: string
owner: string
expiration: Date
Returns Promise<number>
remove
remove(key, owner): Promise<void>
The remove method will remove a lock if it matches the given key and matches the given owner.
Parameters
key: string
owner: null | string
Returns Promise<void>
removeExpiredKeys
removeExpiredKeys(): Promise<void>
Returns Promise<void>
update
update(key, owner, expiration): Promise<number>
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.
The withGroup method returns a new IDatabaseLockAdapter instance that groups locks together.
Only locks in the same group will be acquired and released, leaving locks outside the group unaffected.
To utilize the SqliteLockAdapter, you must install the "better-sqlite3" and "@types/better-sqlite3" packages.
Note the SqliteLockAdapter is limited to single server usage and cannot be shared across multiple servers but it can be shared between different processes. To use it correctly, ensure all process instances access the same consistent, persisted database.
IMPORT_PATH:
"@daiso-tech/core/lock/implementations/adapters"