Node.js - dq
dq is a simple priority queue built on Redis.
Install
npm install --save dq
Usage
connect(config, [callback])
alias: create()
config
: Can take any of the following: a.name
(required) b.port
, defaults to6379
c.host
, defaults '127.0.0.1' d.password
callback
: optional, has signature(err, q)
Example:
var dq = var q = dq // or... dq
count(callback)
callback
: has signature(err, count)
Example:
var dq = var q = dqq
deq([count], callback)
callback
: has signature(err, val)
val
is an Array
if count
was specified.
Example:
var dq = var q = dqq
enq(value, [priority], callback)
value
: (required) data to put in the queue, should be astring
, any non-string will be type coercedpriority
: (optional), defaults to0
, you should choose between0
and1
using the result of Math.random(). Values between-Infinity
andInfinfity
will be accepted.callback
: has signature(err, val)
Example:
var dq = var q = dqq
peak(start, count, [callback])
Return data from start
until start + count
, but don't remove the data.
example:
Assume the queue has the following contents: ['a', 'b', 'c', 'd']
var dq = dq
License
Licensed under MIT. See LICENSE
for more details.
Copyright (c) 2012-2015 JP Richardson