1

I am currently working with kue / node.js

https://github.com/Automattic/kue

After i create and save a job the data will be in my local redis server .

  var job = queue.create('new_job', {
        title: 'welcome email for tj'
        , to: 'tj@learnboost.com'
        , template: 'welcome-email'
    }).save( function(err){
        if( !err ) console.log( job.id );
    });

Redis Cli

127.0.0.1:6379> keys *
 1) "q:job:12"
 2) "q:jobs:inactive"
 3) "q:stats:work-time"
 4) "q:ids"
 5) "q:job:11"
 6) "q:job:7"
 7) "q:search:object:13"
 8) "q:search:word:TTL"
 9) "q:search:object:2"
10) "q:jobs:new_job:inactive"
  ..........

now after i restart my machine and checked again ,

127.0.0.1:6379> keys *
(empty list or set)

So it is empty .

This is obvious , but i want to persist the data , i checked the kue documentation but i could not find anything ?

Is there any way to do this .

thanks in advance .

Kanishka Panamaldeniya
  • 17,302
  • 31
  • 123
  • 193

2 Answers2

3

I think the persistence can be handled by your redis server configuration. In your redis.conf, you have a section commented snapshotting which you should explore. There are a number of ways to configure persistence, but I think what best suits your use case is AOF wherein all incoming writes to the redis server are logged to a file. Please do read about how redis can be configured for persistence here. You can turn on AOF persistence by adding this line to your conf file:

appendonly true
deborah-digges
  • 1,165
  • 11
  • 19
0

Actually, kue doesn't remove jobs unless you delete jobs manually.

Here is an example, saved as test.js:

const kue = require('kue')
const queue = kue.createQueue()
queue.process('echo', (job, done) => {
  console.log(job.data.message)
  done();
})
const job = queue.create('echo', {
  message: 'hello world'
}).save((err) => {
  if (err) {
    console.log(job.id)
  }
})

When I execute via

node test.js

I check queue info in redis, the result of redis-cli keys "q*" is below:

enter image description here

Then I restart node test.js, the result of `redis-cli keys "q*" is below:

enter image description here

Actually, here add a new task: q:job:2. kue will remove a job when you call job.remove. So you should check redis-server's log file to see what happened.

Catarina Ferreira
  • 1,824
  • 5
  • 17
  • 26
fatelei
  • 76
  • 1
  • 4