From 307d0167928833790e84e2f954c12d2bef1ca3b8 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Tue, 16 Aug 2011 09:47:28 -0700 Subject: [PATCH] Changed: one redis connection for all workers now that our ZPOP does not block this is all good --- examples/delayed.js | 2 +- lib/queue/worker.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/delayed.js b/examples/delayed.js index 054b6354..41de539e 100644 --- a/examples/delayed.js +++ b/examples/delayed.js @@ -36,7 +36,7 @@ jobs.create('email', { jobs.promote(); -jobs.process('email', 5, function(job, done){ +jobs.process('email', 10, function(job, done){ setTimeout(function(){ done(); }, Math.random() * 5000); diff --git a/lib/queue/worker.js b/lib/queue/worker.js index 5f2311c8..08a254e0 100644 --- a/lib/queue/worker.js +++ b/lib/queue/worker.js @@ -32,7 +32,7 @@ module.exports = Worker; function Worker(queue, type) { this.queue = queue; this.type = type; - this.client = redis.createClient(); + this.client = Worker.client || (Worker.client = redis.createClient()); this.interval = 1000; }