node-redis-lock
Node.js redis locking system.
Installation
$ npm install node-redis-lock
Use
const Lock = ;const redis = ;const client = redis; // Instantiate a lock.let lock = namespace: 'locking' client; // Acquire a lock.const key = 'job1';const value = 'owned-by-'hostname;const ttl = 1; // secondslock; // Renew a lock.// It fails if the value is different.lock; // Release a lock.// The value has to be passed to ensure another host doesn't release it.lock; // Does a lock exist?lock;
Tests
$ npm test
Author
Philmod <philippe.modard@gmail.com>