This is do-with-redis-lock version 3.2.0, a minimal, promisified library for distributed locking with Redis. It provides a simple `doWithRedisLock` function that acquires a lock via Redis SET NX PX and releases it after the callback resolves. Unlike heavyweight options (e.g., Redlock), this package has zero peer dependencies, no external lock manager, and focuses on a single atomic operation. Releases are infrequent but stable; the current major version (v3) dropped support for Node <18 and switched to ESM-only exports. Key differentiator: simplicity — no retry strategies, no lock extension — just a promise-based lock around an async function.
npm install do-with-redis-lockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to Redis, acquires a distributed lock for `criticalTask`, and releases after completion. Demonstrates options: ttl, retryDelay, retryCount.
Upgrade Node to >=18 and use ESM imports (import syntax). If you need CommonJS, stay on v2.
Use `ttl` instead of `timeout`, and `retryCount` instead of `maxTries`.
Implement your own retry/fallback logic around the call if the lock acquisition fails.
Call `client.connect()` before using the function.
Use `doWithRedisLock` for all locking operations. If you need lower-level control, stay on v2.
Use `import { doWithRedisLock } from 'do-with-redis-lock'` (curly braces).Switch to `import` syntax or use dynamic import: `const { doWithRedisLock } = await import('do-with-redis-lock')`.Upgrade Redis server to >=2.6.12.
Increase retryCount or ttl, or implement a backoff strategy externally.