1

私は現在kue / node.jsで作業しています

https://github.com/Automattic/kue

ジョブを作成して保存すると、データはローカルの redis サーバーに保存されます。

  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 クリ

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"
  ..........

マシンを再起動して再度確認した後、

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

だから空です。

これは明らかですが、データを保持したいので、kue のドキュメントを確認しましたが、何も見つかりませんでした。

これを行う方法はありますか。

前もって感謝します 。

4

2 に答える 2

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.

于 2016-01-08T12:28:45.400 に答える