Retrieves the current lock data for a given key. Used for querying lock state without modifying it.
Readable execution context for the operation
Unique identifier for the lock
Promise resolving to the lock's owner and expiration data if found, otherwise null
Removes a lock from the database regardless of its current owner. Used for administrative cleanup or when the current owner is unavailable.
Readable execution context for the operation
Unique identifier for the lock
Promise resolving to the removed lock's expiration data if a lock existed, otherwise null
Removes a lock from the database only if owned by the specified lockId. Ownership verification prevents accidental deletion of locks held by others.
Readable execution context for the operation
Unique identifier for the lock
The unique identifier of the expected lock owner
Promise resolving to the lock's owner and expiration data if successfully removed, null if the lock wasn't found or the owner didn't match
Executes the provided function within a database transaction. Ensures atomicity of all lock operations (upsert, find) within the transaction. Should use the strictest transaction isolation level to prevent race conditions.
Readable execution context for the operation
Function to execute within the transaction, receives transaction object
Promise resolving to the return value of the transaction function
Updates the expiration time of a lock if owned by the specified lockId. Ownership verification ensures only the lock owner can extend the lock.
Readable execution context for the operation
Unique identifier for the lock
The unique identifier of the expected lock owner
The new date and time when the lock should expire
Promise resolving to the number of locks updated (1 if successful, 0 if not found or ownership mismatch)
Technology-agnostic storage adapter contract for lock persistence in databases. Implementations handle lock data storage using CRUD-capable backends (SQL databases, ORMs like TypeORM/MikroORM, etc.). Provides transactional support for atomic lock updates and consistency guarantees in distributed systems.
IMPORT_PATH:
"@daiso-tech/core/lock/contracts"