node-mutex
How to install
npm install node-mutex
node-mutex
ensures synchronicity of critical
code blocks across multiple nodejs instances. This is achieved with the help of redis
and some clever aproach to managing locks
.
How to use
var mutex = ; mutex;
How to use ( Promise API )
var mutex = ; mutex ;
Options
var mutex = opts;
List of available options:
host
: host to connect redis on (127.0.0.1
)port
: port to connect redis on (6379
)url
: url to connect redis, this option replace values of host and port. Format:[redis:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]
prefix
: port to connect redis on (mutex:
)sleepTime
: maximum time in milliseconds to wait before retrying the acquisition of lock (250
)expireTime
: time in milliseconds before thelock
expires (3000
)pub
: optional, the redis client to publish events onsub
: optional, the redis client to subscribe to events on
License
MIT