Socket
Socket
Sign inDemoInstall

node-redis-warlock

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-redis-warlock - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

4

CHANGELOG.md
Changelog
---
# v0.2.0
* Merge [#18](https://github.com/TheDeveloper/warlock/pull/18): Pass lock id to `.lock` callback.
# v0.1.3

@@ -5,0 +9,0 @@

2

lib/warlock.js

@@ -39,3 +39,3 @@ var crypto = require('crypto');

return cb(err, unlock);
return cb(err, unlock, id);
}

@@ -42,0 +42,0 @@ );

{
"name": "node-redis-warlock",
"version": "0.1.4",
"version": "0.2.0",
"description": "Battle-hardened distributed locking using redis",
"main": "lib/warlock.js",
"scripts": {
"test": "make test"
"test": "mocha -R list ./test/warlock",
"bench": "mocha -R list ./test/bench"
},

@@ -29,7 +30,7 @@ "repository": {

"devDependencies": {
"async": "^1.4.2",
"mocha": "^2.2.5",
"redis": "^0.12.1",
"should": "^7.0.4"
"async": "^1.5.1",
"mocha": "^2.3.4",
"redis": "^2.4.2",
"should": "^8.0.2"
}
}

@@ -60,2 +60,18 @@ warlock

// unlock using the lock id
var key = 'test-lock-2';
var ttl = 10000;
var lockId;
warlock.lock(key, ttl, function(err, _, id) {
lockId = id;
});
// each client who knows the lockId can release the lock
warlock.unlock(key, lockId, function(err, result) {
if(result == 1) {
// unlocked successfully
}
});
```

@@ -62,0 +78,0 @@

@@ -47,1 +47,30 @@ var should = require('should');

});
describe('unlocking with id', function() {
var lockId;
it('sets lock and gets lock id', function(done) {
warlock.lock('customlock', 20000, function(err, unlock, id) {
should.not.exists(err);
id.should.type("string");
lockId = id;
done();
});
});
it('does not unlock with wrong id', function(done) {
warlock.unlock('customlock', "wrongid", function(err, result) {
should.not.exists(err);
result.should.equal(0);
done();
});
});
it('unlocks', function(done) {
warlock.unlock('customlock', lockId, function(err, result) {
should.not.exists(err);
result.should.equal(1);
done();
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc