node-redis-warlock
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -12,3 +12,3 @@ var crypto = require('crypto'); | ||
warlock.makeKey = function(key) { | ||
return 'lock:' + crypto.createHash('md5').update(key).digest('hex').substr(0, 10) | ||
return 'lock:' + crypto.createHash('md5').update(key).digest('hex').substr(0, 10); | ||
}; | ||
@@ -25,5 +25,7 @@ | ||
if (typeof key !== 'string') return cb('lock key must be string'); | ||
if (typeof key !== 'string') return cb(new Error('lock key must be string')); | ||
scripty.loadScriptFile('lock', __dirname + '/lua/lock.lua', function(err, lock){ | ||
if (err) return cb(err); | ||
var timestamp = Date.now(); | ||
@@ -47,3 +49,3 @@ lock.run(3, warlock.makeKey(key), ttl, timestamp, function(err, lockSet) { | ||
if (typeof key !== 'string') return cb('lock key must be string'); | ||
if (typeof key !== 'string') return cb(new Error('lock key must be string')); | ||
@@ -50,0 +52,0 @@ scripty.loadScriptFile('parityDel', __dirname + '/lua/parityDel.lua', function(err, parityDel){ |
{ | ||
"name": "node-redis-warlock", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Battle-hardened distributed locking using redis", | ||
@@ -25,3 +25,3 @@ "main": "lib/warlock.js", | ||
"dependencies": { | ||
"node-redis-scripty": "0.0.3" | ||
"node-redis-scripty": "~0.0.4" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -6,2 +6,11 @@ warlock | ||
## Requirements | ||
* [node-redis](https://github.com/mranney/node_redis) compatible with `v0.10` | ||
* Redis `v2.6` or above | ||
## Install | ||
npm install node-redis-warlock | ||
## Usage | ||
@@ -42,1 +51,6 @@ | ||
``` | ||
## ProTips | ||
* Warlock uses Lua scripting to achieve transactional locking on Redis `v2.6.0` upwards. If you're running Redis `v2.6.12` or above you could use the additional PX and NX arguments for the [SET](http://redis.io/commands/set) operation as an alternative. | ||
* Read my [Distributed locks using Redis](https://engineering.gosquared.com/distributed-locks-using-redis) article and Redis' author's [A proposal for more reliable locks using Redis](http://antirez.com/news/77) to learn more about the theory of distributed locks using Redis. |
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
7154
88
55
+ Addednode-redis-scripty@0.0.6(transitive)
- Removednode-redis-scripty@0.0.3(transitive)
Updatednode-redis-scripty@~0.0.4