Crazy simple redis-backed scheduling


###Crazy simple redis-backed scheduling.###

QueuePasa makes it super easy to schedule messages to be delivered at a later time/date.

It's as easy as qpasa.schedule('Hey', 60000) which will deliver the message 'Hey' in 60,000ms (1 minute).

You can also schedule an exact date and time to deliver instead. Just pass a Date object instead of a delay:

qpasa.schedule('Hey', new Date('May 07 2013 8:00 PM'));

Warning: Don't pass a unix timestamp as an integer (a string is fine) because it will be interpreted as a delay.

qpasa.schedule('Hey', 1367892625698); //Bad! Your message will be delivered in a few decades! 
qpasa.schedule('Hey', "1367892625698"); //However, this works as expected. Just be careful. 
var QueuePasa = require('queuepasa'),
    //These are the current options and their defaults... 
    qpasa = new QueuePasa({
      host: '',
      port: 6379,
      groupBy: 'day',
      interval: 5000,
      delayMultiplier: 1,
      prefix: 'qp'
qpasa.on('item', function(item) {
  console.log('New message: %s', item);
qpasa.schedule('Hey', new Date('May 07 2013 8:00 PM'));

Couldn't be easier.

The options object isn't necessary. You can just use new QueuePasa() if the defaults are to your liking.

host: Where is the Redis instance? default = ''

port: The Redis port. default = 6379

groupBy: QueuePasa speeds things up by placing your queued items in buckets by day. If you have a high volume, you can change this to hour. default = 'day'

interval: How often to check for messages. default = 5000

delayMultiplier: You can have your delay number multiplied. For example, set delayMultiplier to 60000 then your delay argument will be interpreted as minutes instead of miliseconds. default = 1

prefix: The first part of the bucket name. Buckets look something like qp:2013-05-07:z. default = 'qp'