Name: redis-semaphore
Owner: ZEIT
Description: Distributed mutex and semaphore based on Redis
Forked from: swarthy/redis-semaphore
Created: 2018-02-06 20:00:41.0
Updated: 2018-05-03 18:33:38.0
Pushed: 2018-03-19 18:27:16.0
Homepage: null
Size: 51
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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
optionallockTimeout
- 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 intervalt Mutex = require('redis-semaphore').Mutex
t redis = require('redis')
t redisClient = redis.createClient()
c function doSomething() {
nst mutex = new Mutex(redisClient, 'lockingResource')
ait mutex.acquire()
critical code
ait 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
optionallockTimeout
- 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 intervalt Semaphore = require('redis-semaphore').Semaphore
t redis = require('redis')
t redisClient = redis.createClient()
c function doSomething() {
nst semaphore = new Semaphore(redisClient, 'lockingResource', 5)
ait semaphore.acquire()
maximum 5 simultaneously executions
ait semaphore.release()
install --save redis-semaphore
add redis-semaphore
MIT