Search code examples
javascriptnode.jsdatabasepersistencekue

Can I persist data with kue / node.js


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 .


Solution

  • 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