New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-redlock

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-redlock - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

example/example.d.ts

10

package.json
{
"name": "node-redlock",
"version": "1.1.0",
"version": "2.0.0",
"description": "A distributed locking algorithm used to manage distributed resources in a system.",

@@ -8,5 +8,5 @@ "main": "redlock.js",

"scripts": {
"build": "tsc -b",
"test": "mocha -r ts-node/register tests/**/*.test.ts",
"lint": "eslint . --ext .ts"
"build": "tsc -b && cp package.json dist && cp README.md dist",
"test": "mocha -r ts-node/register test/**/*.test.ts",
"lint": "eslint . --ext .ts --fix"
},

@@ -25,3 +25,3 @@ "keywords": [

"randomstring": "^1.2.1",
"redis": "^3.1.2"
"redis": "^4.6.14"
},

@@ -28,0 +28,0 @@ "devDependencies": {

@@ -60,36 +60,1 @@ "use strict";

exports.Redlock = Redlock;
// // Usage example
// import Redis from 'ioredis';
// import { createClient } from 'redis';
// import { IoredisClient } from './IoredisClient';
// import { RedisjsClient } from './RedisjsClient';
// (async () => {
// const ioredisClients = [
// new Redis({ host: 'localhost', port: 6379 }),
// new Redis({ host: 'localhost', port: 6380 }),
// new Redis({ host: 'localhost', port: 6381 }),
// ].map(client => new IoredisClient(client));
// const redisjsClients = [
// createClient({ url: 'redis://localhost:6379' }),
// createClient({ url: 'redis://localhost:6380' }),
// createClient({ url: 'redis://localhost:6381' }),
// ];
// await Promise.all(redisjsClients.map(client => client.connect()));
// const redisjsClientInstances = redisjsClients.map(client => new RedisjsClient(client));
// // Choose the set of clients you want to use
// const clients = [...ioredisClients, ...redisjsClientInstances];
// const redlock = new Redlock(clients);
// const resource = 'locks:example';
// const ttl = 10000; // 10 seconds
// const lock = await redlock.acquireLock(resource, ttl);
// if (lock) {
// console.log(`Acquired lock on ${resource}`);
// // Do your critical section work here
// await redlock.releaseLock(resource, lock.value);
// console.log(`Released lock on ${resource}`);
// } else {
// console.log(`Failed to acquire lock on ${resource}`);
// }
// ioredisClients.forEach(client => (client as IoredisClient).client.quit());
// await Promise.all(redisjsClients.map(client => client.quit()));
// })();
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