🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

redis-semaphore

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-semaphore - npm Package Compare versions

Comparing version

to
1.0.0

1

lib/fair-semaphore/index.js

@@ -6,3 +6,2 @@ const TimeoutError = require('../errors/TimeoutError')

const uuid4 = require('uuid/v4')
require('../utils/promisifyRedis')

@@ -9,0 +8,0 @@ function getKey(key) {

@@ -15,9 +15,3 @@ const debug = require('debug')('redis-semaphore:mutex:acquire')

debug(key, identifier, 'attempt')
const result = await client.setAsync(
key,
identifier,
'NX',
'PX',
lockTimeout
)
const result = await client.set(key, identifier, 'NX', 'PX', lockTimeout)
debug('result', typeof result, result)

@@ -24,0 +18,0 @@ if (result === 'OK') {

@@ -6,3 +6,2 @@ const TimeoutError = require('../errors/TimeoutError')

const uuid4 = require('uuid/v4')
require('../utils/promisifyRedis')

@@ -9,0 +8,0 @@ function getKey(key) {

6

lib/RedisMutex.js

@@ -1,2 +0,2 @@

const RedisClient = require('redis').RedisClient
const Redis = require('ioredis')
const LostLockError = require('./errors/LostLockError')

@@ -28,4 +28,4 @@ const debug = require('debug')('redis-semaphore:mutex:instance')

}
if (!(client instanceof RedisClient)) {
throw new Error('"client" must be instance of RedisClient')
if (!(client instanceof Redis)) {
throw new Error('"client" must be instance of ioredis client')
}

@@ -32,0 +32,0 @@ if (!key) {

@@ -6,3 +6,2 @@ const TimeoutError = require('../errors/TimeoutError')

const uuid4 = require('uuid/v4')
require('../utils/promisifyRedis')

@@ -9,0 +8,0 @@ function getKey(key) {

@@ -5,3 +5,3 @@ const debug = require('debug')('redis-semaphore:semaphore:release')

debug(key, identifier)
const result = await client.zremAsync(key, identifier)
const result = await client.zrem(key, identifier)
debug('result', typeof result, result)

@@ -8,0 +8,0 @@ return result === 1

@@ -12,3 +12,3 @@ const debug = require('debug')('redis-semaphore:eval')

function isNoScriptError(err) {
return err.command === 'EVALSHA' && err.code === 'NOSCRIPT'
return err.command.name === 'evalsha' && err.message.startsWith('NOSCRIPT')
}

@@ -25,3 +25,3 @@

try {
return await client.evalshaAsync(evalSHAArgs)
return await client.evalsha(evalSHAArgs)
} catch (err) {

@@ -31,3 +31,3 @@ if (isNoScriptError(err)) {

debug(sha1, 'fallback to eval, args:', evalArgs)
return await client.evalAsync(evalArgs)
return await client.eval(evalArgs)
} else {

@@ -34,0 +34,0 @@ throw err

{
"name": "redis-semaphore",
"version": "0.3.3",
"version": "1.0.0",
"description": "Distributed mutex and semaphore based on Redis",

@@ -26,2 +26,3 @@ "main": "index.js",

"benchmark": "^2.1.4",
"bluebird": "^3.5.2",
"chai": "4.1.2",

@@ -32,5 +33,5 @@ "chai-as-promised": "7.1.1",

"eslint-plugin-node": "7.0.1",
"ioredis": "^4.1.0",
"istanbul": "0.4.5",
"mocha": "5.2.0",
"redis": "^2.8.0",
"sinon": "6.1.5",

@@ -44,6 +45,5 @@ "sinon-chai": "3.2.0",

"peerDependencies": {
"redis": "^2.8.0"
"ioredis": "^4.1.0"
},
"dependencies": {
"bluebird": "^3.5.1",
"debug": "^3.1.0",

@@ -50,0 +50,0 @@ "uuid": "^3.3.2"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet