Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use node-uuid instead of redis id coounters.

  • Loading branch information...
commit b50622a90eecc9a9f494b8af828ff938c9f62999 1 parent bd8fac5
@tim-smart tim-smart authored
Showing with 14 additions and 17 deletions.
  1. +10 −16 index.js
  2. +4 −1 package.json
View
26 index.js
@@ -3,6 +3,7 @@
*/
var redis = require('./deps/node-redis'),
events = require('events'),
+ uuid = require('node-uuid'),
util = require('util');
/**
@@ -60,26 +61,19 @@ exports.Queue = Queue;
Queue.prototype.push = function (payload, callback) {
var self = this;
- // Get an ID from redis
- this.client.incr(this.prefix + 'id:' + this.name, function (error, id) {
+ // Push the job.
+ self.client.rpush(self.prefix + 'queue:' + self.name, JSON.stringify({
+ id: uuid(),
+ payload: payload,
+ error_count: 0,
+ errors: [],
+ modified: Date.now()
+ }), function (error, length) {
if (error) {
return handleError(error, callback);
}
- // Push the job.
- self.client.rpush(self.prefix + 'queue:' + self.name, JSON.stringify({
- id: id,
- payload: payload,
- error_count: 0,
- errors: [],
- modified: Date.now()
- }), function (error, length) {
- if (error) {
- return handleError(error, callback);
- }
-
- if (callback) callback(null, id);
- });
+ if (callback) callback(null, id);
});
};
View
5 package.json
@@ -4,5 +4,8 @@
"version": "0.1.1",
"author": "Tim Smart",
"engine": [ "node >=0.3.6" ],
- "main": "./"
+ "main": "./",
+ "dependencies": {
+ "node-uuid": ">1.1.0"
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.