
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
redis-semaphore
Advanced tools
Mutex and Semaphore implementations based on Redis ready for distributed systems
redisClient
- required, configured redis
clientkey
- required, key for locking resource (final key in redis: mutex:<key>
)timeouts
optional
lockTimeout
- ms, time after mutex will be auto released (expired)acquireTimeout
- ms, max timeout for .acquire()
callretryInterval
- ms, time between acquire attempts if resource lockedrefreshInterval
- ms, auto-refresh intervalconst Mutex = require('redis-semaphore').Mutex
const redis = require('redis')
const redisClient = redis.createClient()
async function doSomething() {
const mutex = new Mutex(redisClient, 'lockingResource')
await mutex.acquire()
// critical code
await mutex.release()
}
redisClient
- required, configured redis
clientkey
- required, key for locking resource (final key in redis: semaphore:<key>
)maxCount
- required, maximum simultaneously resource usage counttimeouts
optional
lockTimeout
- ms, time after semaphore will be auto released (expired)acquireTimeout
- ms, max timeout for .acquire()
callretryInterval
- ms, time between acquire attempts if resource lockedrefreshInterval
- ms, auto-refresh intervalconst Semaphore = require('redis-semaphore').Semaphore
const redis = require('redis')
const redisClient = redis.createClient()
async function doSomething() {
const semaphore = new Semaphore(redisClient, 'lockingResource', 5)
await semaphore.acquire()
// maximum 5 simultaneously executions
await semaphore.release()
}
redisClient
- required, configured redis
clientkey
- required, key for locking resource (final key in redis: semaphore:<key>
)maxCount
- required, maximum simultaneously resource usage counttimeouts
optional
lockTimeout
- ms, time after semaphore will be auto released (expired)acquireTimeout
- ms, max timeout for .acquire()
callretryInterval
- ms, time between acquire attempts if resource lockedrefreshInterval
- ms, auto-refresh intervalconst FairSemaphore = require('redis-semaphore').FairSemaphore
const redis = require('redis')
const redisClient = redis.createClient()
async function doSomething() {
const semaphore = new FairSemaphore(redisClient, 'lockingResource', 5)
await semaphore.acquire()
// maximum 5 simultaneously executions
await semaphore.release()
}
npm install --save redis-semaphore
# or
yarn add redis-semaphore
MIT
FAQs
Distributed mutex and semaphore based on Redis
The npm package redis-semaphore receives a total of 202,717 weekly downloads. As such, redis-semaphore popularity was classified as popular.
We found that redis-semaphore demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.