redis-event-queue
v1.1.5
Published
Interprocess queue based on Redis that implements EventEmitter interface
Downloads
4
Maintainers
Readme
redis-event-queue
Interprocess queue based on Redis that implements EventEmitter interface
Install
npm install --save redis-event-queue
Usage
Emmiter
var req = require('redis-event-queue')(options);
var wqueue = req.workqueue;
var bqueue = req.broadcast;
for(var i = 0; i < 10; i++) {
wqueue.emit('event', 'work msg '+i);
bqueue.emit('event', 'broad msg '+i);
}
Listener
var req = require('redis-event-queue')(options);
var wqueue = req.workqueue;
var bqueue = req.broadcast;
wqueue.on('event', function(msg) {
console.log('work: '+msg);
});
bqueue.on('event', function(msg) {
console.log('broad: '+msg);
});
options
- prefix: Set keys prefix to use in redis.
All other options are the same as described in redis.
workqueue
Delivers a message to the first process available
broadcast
Delivers a message to all processes listening
#Next
Add optional pattern to listen to messages in workqueue an broadcast
#Suggestions
If you have any suggestions, comments or bug reports, please add an issue in github or PR directly!
Thanks.