Locks Actions
Locks actions enable you to coordinate access to shared resources and prevent race conditions. This is essential for implementing the Exclusivity Pattern in your workflows.
Available Operations
Lock Actions
- Acquire a lock - Request exclusive access to a resource
- Check if a lock exists - Verify if a resource is currently locked
- Release a lock - Free a resource for other processes
Acquire a lock
Request exclusive access to a resource.
Acquire Lock Configuration
| Parameter | Type | Required | Description |
|---|---|---|---|
| Lock Name | String | Yes | Unique name for the lock |
| Timeout | String | No | Maximum time to wait for lock (e.g., "30s") |
| TTL | String | No | How long to hold the lock (e.g., "5m") |
| Metadata | Object | No | Additional data to store with the lock |
Acquire Lock Example
{
"key": "file-processing-12345",
"ttl": 300
}
Acquire Lock Response
{
"success": true,
"data": {
"id": "lock123",
"key": "file-processing-12345",
"appId": "app123",
"expiresAt": "2024-01-01T10:05:00.000Z",
"createdAt": "2024-01-01T10:00:00.000Z"
}
}
Release a lock
Free a resource for other processes.
Release Lock Configuration
| Parameter | Type | Required | Description |
|---|---|---|---|
| Lock Name | String | Yes | Name of the lock to release |
| Lock ID | String | Yes | ID of the lock to release |
Release Lock Example
{
"key": "file-processing-12345"
}
Release Lock Response
{
"success": true,
"data": {
"released": true,
"key": "file-processing-12345",
"releasedAt": "2024-01-01T10:00:00.000Z"
}
}
Check if a lock exists
Verify if a resource is currently locked and get lock details.
Check Lock Configuration
| Parameter | Type | Required | Description |
|---|---|---|---|
| Lock Name | String | Yes | Name of the lock to check |
Check Lock Example
{
"key": "file-processing-12345"
}
Check Lock Response
{
"success": true,
"data": {
"exists": true,
"lock": {
"id": "lock123",
"key": "file-processing-12345",
"appId": "app123",
"expiresAt": "2024-01-01T10:05:00.000Z",
"createdAt": "2024-01-01T10:00:00.000Z"
}
}
}
Common Patterns
Exclusivity Pattern
Implement the exclusivity pattern for resource coordination:
- Acquire lock for resource
- If acquired: Process resource
- Release lock after processing
// Step 1: Acquire Lock
{
"key": "file-processing-{{ $json.filename }}",
"ttl": 300
}
// Step 2: Process if lock acquired
// (Use IF node with condition: 8kit.data.id exists)
// Step 3: Release Lock after processing
{
"key": "file-processing-{{ $json.filename }}"
}
Lock Timeout
Handle cases where locks cannot be acquired:
{
"key": "resource-123",
"ttl": 120
}
Next Steps
Ready to explore more actions? Check out:
- Last Updated Actions - Enable incremental polling
- App Info Actions - Monitor system health