Permalink
Browse files

node-redis update

  • Loading branch information...
1 parent e1f8055 commit 6769a193577b5f14db338a74f4ffbf476abef43e @tim-smart tim-smart committed Jan 24, 2011
Showing with 45 additions and 43 deletions.
  1. +1 −0 deps/node-redis/.gitignore
  2. +32 −31 deps/node-redis/bench.js
  3. +1 −1 deps/node-redis/index.js
  4. +11 −11 index.js
View
1 deps/node-redis/.gitignore
@@ -1,2 +1,3 @@
tags
dump.rdb
+bench/
View
63 deps/node-redis/bench.js
@@ -1,18 +1,19 @@
var redis = require('./'),
- redis2 = require('./bench/node_redis'),
- redis3 = require('./bench/redis-node/redis'),
- redis4 = require('./bench/redis-client'),
+ redis2 = require('redis'),
+ //redis3 = require('./bench/redis-node/redis'),
+ //redis4 = require('./bench/redis-client'),
Seq = require('parallel').Sequence,
assert = require('assert');
var clients = { 'node-redis': redis.createClient(), 'node_redis': redis2.createClient(),
- 'redis-node': redis3.createClient(), 'redis-node-client': redis4.createClient() }
+ /*'redis-node': redis3.createClient(), 'redis-node-client': redis4.createClient()*/ }
-var iterations = 7500,
+var iterations = 5000,
number = 3;
//var buffer = require('fs').readFileSync('binary');
var buffer = new Buffer(Array(1025 * 2).join('x'));
+//var buffer = Array(1025 * 2).join('x');
//var buffer = 'Some some random text for the benchmark.';
//var buffer = 'xxx';
@@ -35,32 +36,32 @@ var benches = {
}
client.del('bench' + i, callback);
},
- //lpush: function (client, callback) {
- //for (var i = 0; i < iterations - 1; i++) {
- //client.lpush('bench', buffer);
- //}
- //client.lpush('bench', buffer, callback);
- //},
- //lrange: function (client, callback) {
- //for (var i = 0; i < iterations - 1; i++) {
- //client.lrange('bench', 0, 99);
- //}
- //client.lrange('bench', 0, 99, callback);
- //},
- //hmset: function (client, callback) {
- //if ('redis-node' === client._name) return callback();
- //for (var i = 0; i < iterations - 1; i++) {
- //client.hmset('bench' + i, 'key', buffer, 'key2', buffer);
- //}
- //client.hmset('bench' + i, 'key', buffer, 'key2', buffer, callback);
- //},
- //hmget: function (client, callback) {
- //if ('redis-node' === client._name) return callback();
- //for (var i = 0; i < iterations - 1; i++) {
- //client.hmget('bench' + i, 'key', 'key2');
- //}
- //client.hmget('bench' + i, 'key', 'key2', callback);
- //},
+ lpush: function (client, callback) {
+ for (var i = 0; i < iterations - 1; i++) {
+ client.lpush('bench', buffer);
+ }
+ client.lpush('bench', buffer, callback);
+ },
+ lrange: function (client, callback) {
+ for (var i = 0; i < iterations - 1; i++) {
+ client.lrange('bench', 0, 99);
+ }
+ client.lrange('bench', 0, 99, callback);
+ },
+ hmset: function (client, callback) {
+ if ('redis-node' === client._name) return callback();
+ for (var i = 0; i < iterations - 1; i++) {
+ client.hmset('bench' + i, 'key', buffer, 'key2', buffer);
+ }
+ client.hmset('bench' + i, 'key', buffer, 'key2', buffer, callback);
+ },
+ hmget: function (client, callback) {
+ if ('redis-node' === client._name) return callback();
+ for (var i = 0; i < iterations - 1; i++) {
+ client.hmget('bench' + i, 'key', 'key2');
+ }
+ client.hmget('bench' + i, 'key', 'key2', callback);
+ },
};
var task = new Seq(),
View
2 deps/node-redis/index.js
@@ -2,7 +2,7 @@ var net = require('net'),
utils = require('./utils'),
Parser = require('./parser');
-var RedisClient = function RedisClient(host, port) {
+var RedisClient = function RedisClient(port, host) {
this.host = host;
this.port = port;
this.stream = net.createConnection(port, host);;
View
22 index.js
@@ -34,15 +34,15 @@ var removePrefix = function (prefix, string) {
*
* @constructor
* @param {String} name: The queue name.
- * @param {String} host: The host name for the Redis client.
* @param {Number} port: The port number for the Redis client.
+ * @param {String} host: The host name for the Redis client.
* @param {String} auth: If the redis host requires an AUTH command.
*/
-var Queue = function (name, host, port, auth) {
+var Queue = function (name, port, host, auth) {
var self = this;
this.name = name;
- this.client = redis.createClient(host, port);
+ this.client = redis.createClient(port, host);
this.prefix = 'queue:';
if (auth) {
@@ -61,13 +61,13 @@ util.inherits(Queue, events.EventEmitter);
* Creates a new Queue object.
*
* @param {String} name: The queue name.
- * @param {String} host: The host name for the Redis client.
* @param {Number} port: The port number for the Redis client.
+ * @param {String} host: The host name for the Redis client.
* @param {String} auth: If the redis host requires an AUTH command.
* @returns {Queue}
*/
-exports.createQueue = function (name, host, port, auth) {
- return new Queue(name, host, port, auth);
+exports.createQueue = function (name, port, host, auth) {
+ return new Queue(name, port, host, auth);
};
exports.Queue = Queue;
@@ -111,11 +111,11 @@ Queue.prototype.push = function (payload, callback) {
*
* @constructor
* @param {String} name: The queue name.
- * @param {String} host: The host name for the Redis client.
* @param {Number} port: The port number for the Redis client.
+ * @param {String} host: The host name for the Redis client.
* @param {String} auth: If the redis host requires an AUTH command.
*/
-var Worker = function (name, host, port, auth) {
+var Worker = function (name, port, host, auth) {
var self = this;
// Call parent
@@ -161,13 +161,13 @@ util.inherits(Worker, events.EventEmitter);
* Creates a new Worker object.
*
* @param {String} name: The queue name.
- * @param {String} host: The host name for the Redis client.
* @param {Number} port: The port number for the Redis client.
+ * @param {String} host: The host name for the Redis client.
* @param {String} auth: If the redis host requires an AUTH command.
* @returns {Worker}
*/
-exports.createWorker = function (name, host, port, auth) {
- return new Worker(name, host, port, auth);
+exports.createWorker = function (name, port, host, auth) {
+ return new Worker(name, port, host, auth);
};
exports.Worker = Worker;

0 comments on commit 6769a19

Please sign in to comment.