Skip to content

Instantly share code, notes, and snippets.

@GeoffreyPlitt
Created December 12, 2014 05:15
Show Gist options
  • Save GeoffreyPlitt/a1b8866c982817c97dfb to your computer and use it in GitHub Desktop.
Save GeoffreyPlitt/a1b8866c982817c97dfb to your computer and use it in GitHub Desktop.
Kue with fake_redis
var fake_redis = require("fakeredis");
var QUEUE_NAME = 'incoming_mturk_events';
var concurrency = 1;
var max_size = 10;
var kue = require('kue');
var in_memory_queue = kue.createQueue({
redis: {
createClientFactory: function(){
return fake_redis.createClient('my_fake_redis');
}
}
});
in_memory_queue.process(QUEUE_NAME, concurrency, function(job, done) {
setTimeout(function(){
console.log('gp1', job.data);
done();
}, 1000);
});
in_memory_queue.create(QUEUE_NAME, {a:1}).save(function(err){if(err) console.log(err);});
in_memory_queue.create(QUEUE_NAME, {a:2}).save(function(err){if(err) console.log(err);});
in_memory_queue.create(QUEUE_NAME, {a:3}).save(function(err){if(err) console.log(err);});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment