cache_lock_acquire
Acquire a distributed lock with automatic expiration to prevent deadlocks in Redis-based systems. Returns a fencing token for secure resource management.
Instructions
Acquire a distributed lock using Redis SET NX PX (Redlock-lite). Returns a fencing token on success. The lock auto-expires after ttl_ms to prevent deadlocks. Use cache_lock_release to free the lock early.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instance_id | Yes | UUID of the cache instance | |
| key | Yes | Lock resource identifier | |
| ttl_ms | Yes | Safety TTL in milliseconds (e.g. 5000) | |
| retries | No | Max acquire attempts (default: 3) | |
| retry_delay_ms | No | Milliseconds between retries (default: 50) |