node-redis-warlock
Advanced tools
Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "node-redis-warlock", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Battle-hardened distributed locking using redis", | ||
@@ -24,2 +24,5 @@ "main": "lib/warlock.js", | ||
"homepage": "https://github.com/thedeveloper/warlock", | ||
"dependencies": { | ||
"node-redis-scripty": "0.0.2" | ||
}, | ||
"devDependencies": { | ||
@@ -29,6 +32,3 @@ "should": "^3.1.3", | ||
"redis": "^0.10.1" | ||
}, | ||
"dependencies": { | ||
"node-redis-scripty": "0.0.2" | ||
} | ||
} |
warlock | ||
======= | ||
Battle-hardened distributed locking using redis | ||
Battle-hardened distributed locking using redis. | ||
## Usage | ||
```javascript | ||
var Warlock = require('node-redis-warlock'); | ||
var redis = require('redis'); | ||
// Establish a redis client and pass it to warlock | ||
var redis = redis.createClient(); | ||
var warlock = Warlock(redis); | ||
// Set a lock | ||
var key = 'test-lock'; | ||
var ttl = 10000; | ||
warlock.lock(key, ttl, function(err, unlock){ | ||
if (err) { | ||
// Something went wrong and we weren't able to set a lock | ||
return; | ||
} | ||
if (typeof unlock === 'function') { | ||
// If the lock is set successfully by this process, an unlock function is passed to our callback. | ||
// Do the work that required lock protection, and then unlock() when finished... | ||
// | ||
// do stuff... | ||
// | ||
unlock(); | ||
} else { | ||
// Otherwise, the lock was not established by us so we must decide what to do | ||
// Perhaps wait a bit & retry... | ||
} | ||
}); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6386
41