Removes all slots from a semaphore. Used for cleanup or reset operations. Returns expiration info for all removed slots.
Readable execution context for the operation
The semaphore identifier
Array of expiration info for all removed slots
Removes a specific slot, making that resource unit available again. Returns the slot's expiration info. Returns null if slot doesn't exist (idempotent - safe to call multiple times).
Readable execution context for the operation
The semaphore identifier
The slot to remove
Expiration info of the removed slot, or null if not found
Executes a function within a database transaction. Ensures all operations in the function are atomic and isolated.
Implementations must use the strictest transaction isolation level available (SERIALIZABLE for SQL, highest for document databases) to prevent race conditions.
Readable execution context for the operation
Async function receiving transaction object, returns value of any type
The value returned by the function
Updates a slot's expiration time if it's currently valid (not expired). Useful for extending a held slot's lifetime (e.g., heartbeat/keep-alive).
Conditions for success:
Readable execution context for the operation
The semaphore identifier
The slot to update
New expiration time (or null for persistent)
Number of rows affected (1 if updated, 0 if slot not found or expired)
Database adapter contract for managing semaphores in SQL/document databases. Simplifies semaphore implementation using transactional CRUD patterns.
Designed for persistent semaphores stored in databases like:
IMPORT_PATH:
"@daiso-tech/core/semaphore/contracts"