Comparing version 0.1.8 to 0.1.9
@@ -0,1 +1,15 @@ | ||
v0.1.9 | ||
====== | ||
- [Improvement] Faster job removal. (manast) | ||
v0.1.8 | ||
====== | ||
- [Improvement] Better promisification of redis methods. (manast) | ||
v0.1.7 | ||
====== | ||
- [Feature] Added a convenience method for getting a job. (loginx) | ||
- [Fix] Only set a redis db from options if defined. (jboga) | ||
- [Fix] Fixed issue #52. (manast) | ||
v0.1.6 | ||
@@ -2,0 +16,0 @@ ====== |
"use strict"; | ||
var redis = require('redis'); | ||
var Promise = require('bluebird'); | ||
var _ = require('lodash'); | ||
@@ -120,14 +121,37 @@ /** | ||
/** | ||
Removes a job from the queue and from all the lists where it may be. | ||
Removes a job from the queue and from all the lists where it may be stored. | ||
*/ | ||
Job.prototype.remove = function(){ | ||
var queue = this.queue; | ||
return queue.multi() | ||
.lrem(queue.toKey('active'), 0, this.jobId) | ||
.lrem(queue.toKey('wait'), 0, this.jobId) | ||
.lrem(queue.toKey('paused'), 0, this.jobId) | ||
.srem(queue.toKey('completed'), this.jobId) | ||
.srem(queue.toKey('failed'), this.jobId) | ||
.del(queue.toKey(this.jobId)) | ||
.execAsync(); | ||
var script = [ | ||
'if (redis.call("SISMEMBER", KEYS[4], ARGV[1]) == 0) and (redis.call("SISMEMBER", KEYS[5], ARGV[1]) == 0) then', | ||
' redis.call("LREM", KEYS[1], 0, ARGV[1])', | ||
' redis.call("LREM", KEYS[2], 0, ARGV[1])', | ||
' redis.call("LREM", KEYS[3], 0, ARGV[1])', | ||
'end', | ||
'redis.call("SREM", KEYS[4], ARGV[1])', | ||
'redis.call("SREM", KEYS[5], ARGV[1])', | ||
'redis.call("DEL", KEYS[6])'].join('\n'); | ||
var keys = _.map([ | ||
'active', | ||
'wait', | ||
'paused', | ||
'completed', | ||
'failed', | ||
this.jobId], function(name){ | ||
return queue.toKey(name); | ||
}); | ||
return this.queue.client.evalAsync( | ||
script, | ||
keys.length, | ||
keys[0], | ||
keys[1], | ||
keys[2], | ||
keys[3], | ||
keys[4], | ||
keys[5], | ||
this.jobId); | ||
} | ||
@@ -134,0 +158,0 @@ |
{ | ||
"name": "bull", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "Job manager", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53047
15
1356