Atomically increments a counter and returns the new value.
The key to increment
The new value after incrementing
Attempts to acquire a distributed lock with automatic expiration.
The lock key
Time-to-live in seconds (automatic expiration)
A unique lock ID if acquired, null if lock is already held
This operation MUST be atomic and follow the "SET NX EX" semantics:
The lock ID should be a unique value (e.g., UUID or timestamp+random) that prevents accidental release by other processes.
Releases a previously acquired lock.
The lock key
The unique ID returned by acquireLock
Gets the value associated with a key.
The key to retrieve
The stored value, or null if not found
OptionalsetSets a key-value pair with expiration.
The key to set
The value to store
Time-to-live in seconds
OptionaldeleteOptionalevalExecutes an atomic script (e.g., Lua in Redis, stored procedure in SQL).
The script to execute
Array of keys the script will operate on
Array of arguments to pass to the script
The script's return value
This is an optional method that allows execution of atomic scripts for complex operations that require multiple steps to be atomic. Not all stores support this - simple stores may omit it.
For Redis: executes a Lua script For PostgreSQL: executes a stored procedure or CTE For DynamoDB: might use TransactWrite
Interface for atomic storage operations required by the SDK's distributed components.
Remarks
Implementations of this interface MUST guarantee atomicity for all operations. These primitives are used by the SDK's internal components to coordinate distributed state in multi-instance deployments (e.g., serverless functions).
The SDK provides a reference Redis implementation, but you can implement this interface using any storage backend that supports atomic operations:
Example