passkey 3.0.0 provides a shared lock (mutex) built on top of Redis. It enables distributed locking with atomic acquire and release, automatic TTL expiration, and lock extension. Compared to alternatives, it uses Redis's atomic operations for reliability and supports promise-based API. The package is minimal, with no external dependencies beyond Redis, and is intended for Node.js environments. Release cadence is low; last major version was v3.
npm install passkeyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows acquiring a lock, performing work, extending TTL, and releasing, with error handling for LockError.
Use import { LockError } from 'passkey' for ESM, or passkey.LockError for CommonJS.Always attach .catch or use try/catch with async/await to handle LockError.
Call client.connect() before passing to passkey. For redis@3.x, connection is auto; for redis@4.x, explicit connect is required.
Retry the lock with backoff or handle the error gracefully.
Use redis.createClient() (without 'new') and ensure the client is properly imported.
Ensure you are using default import: import passkey from 'passkey'. For CommonJS: const passkey = require('passkey').