Socket
Socket
Sign inDemoInstall

ioredis

Package Overview
Dependencies
Maintainers
1
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ioredis - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

202

benchmark.js
var nodeRedis = require('redis');
var ioRedis = require('./');
var ndredis, ioredis;
var thunkRedis = require('thunk-redis');
var waitReady = function (next) {
setTimeout(function () {
next();
}, 2000);
// var pending = 2;
// ndredis.on('ready', function () {
// if (!--pending) {
// next();
// }
// });
var pending = 2;
ndredis.on('ready', function () {
if (!--pending) {
next();
}
});
// ioredis.on('ready', function () {
// if (!--pending) {
// next();
// }
// });
ioredis.on('ready', function () {
if (!--pending) {
next();
}
});
};

@@ -28,8 +24,4 @@

before(function (start) {
tkredis = thunkRedis.createClient(6380);
ioredis = new ioRedis.Cluster([
{ port: 6380, host: '127.0.0.1' },
{ port: 6381, host: '127.0.0.1' },
{ port: 6382, host: '127.0.0.1' }
]);
ndredis = nodeRedis.createClient();
ioredis = new ioRedis();
waitReady(start);

@@ -43,102 +35,102 @@ });

bench('node_redis', function(next) {
tkredis.set('foo', 'bar')(next);
ndredis.set('foo', 'bar', next);
});
after(function () {
// ndredis.quit();
// ioredis.quit();
ndredis.quit();
ioredis.quit();
});
});
// suite('simple get', function() {
// set('mintime', 5000);
// set('concurrency', 50);
// before(function (start) {
// ndredis = nodeRedis.createClient();
// ioredis = new ioRedis();
// waitReady(function () {
// ndredis.set('foo', 'bar', start);
// });
// });
suite('simple get', function() {
set('mintime', 5000);
set('concurrency', 50);
before(function (start) {
ndredis = nodeRedis.createClient();
ioredis = new ioRedis();
waitReady(function () {
ndredis.set('foo', 'bar', start);
});
});
// bench('ioredis', function(next) {
// ioredis.get('foo', next);
// });
bench('ioredis', function(next) {
ioredis.get('foo', next);
});
// bench('node_redis', function(next) {
// ndredis.get('foo', next);
// });
bench('node_redis', function(next) {
ndredis.get('foo', next);
});
// after(function () {
// ndredis.quit();
// ioredis.quit();
// });
// });
after(function () {
ndredis.quit();
ioredis.quit();
});
});
// suite('simple get with pipeline', function() {
// set('mintime', 5000);
// set('concurrency', 50);
// before(function (start) {
// ndredis = nodeRedis.createClient();
// ioredis = new ioRedis();
// waitReady(function () {
// ndredis.set('foo', 'bar', start);
// });
// });
suite('simple get with pipeline', function() {
set('mintime', 5000);
set('concurrency', 50);
before(function (start) {
ndredis = nodeRedis.createClient();
ioredis = new ioRedis();
waitReady(function () {
ndredis.set('foo', 'bar', start);
});
});
// bench('ioredis', function(next) {
// var pipeline = ioredis.pipeline();
// for (var i = 0; i < 10; ++i) {
// pipeline.get('foo');
// }
// pipeline.exec(next);
// });
bench('ioredis', function(next) {
var pipeline = ioredis.pipeline();
for (var i = 0; i < 10; ++i) {
pipeline.get('foo');
}
pipeline.exec(next);
});
// bench('node_redis', function(next) {
// var pending = 0;
// for (var i = 0; i < 10; ++i) {
// pending += 1;
// ndredis.get('foo', check);
// }
// function check() {
// if (!--pending) {
// next();
// }
// }
// });
bench('node_redis', function(next) {
var pending = 0;
for (var i = 0; i < 10; ++i) {
pending += 1;
ndredis.get('foo', check);
}
function check() {
if (!--pending) {
next();
}
}
});
// after(function () {
// ndredis.quit();
// ioredis.quit();
// });
// });
after(function () {
ndredis.quit();
ioredis.quit();
});
});
// suite('lrange 100', function() {
// set('mintime', 5000);
// set('concurrency', 50);
// before(function (start) {
// ndredis = nodeRedis.createClient();
// ioredis = new ioRedis();
// waitReady(function () {
// var item = [];
// for (var i = 0; i < 100; ++i) {
// item.push((Math.random() * 100000 | 0) + 'str');
// }
// ndredis.del('foo');
// ndredis.lpush('foo', item, start);
// });
// });
suite('lrange 100', function() {
set('mintime', 5000);
set('concurrency', 50);
before(function (start) {
ndredis = nodeRedis.createClient();
ioredis = new ioRedis();
waitReady(function () {
var item = [];
for (var i = 0; i < 100; ++i) {
item.push((Math.random() * 100000 | 0) + 'str');
}
ndredis.del('foo');
ndredis.lpush('foo', item, start);
});
});
// bench('ioredis', function(next) {
// ioredis.lrange('foo', 0, 99, next);
// });
bench('ioredis', function(next) {
ioredis.lrange('foo', 0, 99, next);
});
// bench('node_redis', function(next) {
// ndredis.lrange('foo', 0, 99, next);
// });
bench('node_redis', function(next) {
ndredis.lrange('foo', 0, 99, next);
});
// after(function () {
// ndredis.quit();
// ioredis.quit();
// });
// });
after(function () {
ndredis.quit();
ioredis.quit();
});
});
## Changelog
### v1.0.9 - April 25, 2015
* [ADD] Support for single node commands in cluster mode.
### v1.0.8 - April 25, 2015
* [Add] Promise support for Cluster
### v1.0.7 - April 25, 2015

@@ -4,0 +12,0 @@

@@ -5,2 +5,3 @@ var Promise = require('bluebird');

var utils = require('./utils');
var commands = require('ioredis-commands');

@@ -13,3 +14,11 @@ function ClusterCommand (command, callback) {

var key = this.args[0];
// get first key
var key;
var def = commands[this.name];
if (def) {
var keyPosition = def.keyStart - 1;
if (keyPosition >= 0 && keyPosition < this.args.length) {
key = this.args[keyPosition];
}
}
if (key) {

@@ -16,0 +25,0 @@ this.slot = utils.calcSlot(key);

@@ -6,7 +6,5 @@ var _ = require('lodash');

var commands = _.difference(_.uniq(_.keys(require('ioredis-commands')).map(function (commandName) {
return commandName.split(' ')[0].toLowerCase();
})), ['monitor']);
var commands = _.difference(_.keys(require('ioredis-commands'), ['monitor']));
commands.push('sentinel', 'asking');
commands.push('sentinel', 'quit');

@@ -13,0 +11,0 @@ _.forEach(commands, function (commandName) {

@@ -137,5 +137,2 @@ var Redis = require('./redis');

RedisCluster.prototype.sendCommand = function (command) {
if (command.args.length === 0) {
return command.reject(new Error('Invalid command ' + command.name + ' in cluster mode'));
}
var _this = this;

@@ -174,3 +171,3 @@

var redis;
if (random) {
if (random || typeof clusterCommand.slot === 'undefined') {
redis = _this.nodes[_.sample(Object.keys(_this.nodes))];

@@ -185,3 +182,2 @@ } else if (asking) {

redis.sendCommand(clusterCommand);
// not connected
} else if (_this.options.enableOfflineQueue) {

@@ -188,0 +184,0 @@ _this.offlineQueue.push(command);

{
"name": "ioredis",
"version": "1.0.8",
"version": "1.0.9",
"description": "A delightful, performance-focused Redis client for Node and io.js",

@@ -31,3 +31,3 @@ "main": "index.js",

"flexbuffer": "0.0.6",
"ioredis-commands": "^3.0.0",
"ioredis-commands": "4.0.0",
"lodash": "^3.6.0"

@@ -34,0 +34,0 @@ },

@@ -407,3 +407,3 @@ # ioredis

## Cluster
Support for Cluster is currently experimental. It's not recommended to use it in production.
Support for Cluster is currently experimental and under active development. It's not recommended to use it in production.
If you encounter any problems, welcome to submit an issue :-).

@@ -410,0 +410,0 @@

@@ -7,8 +7,8 @@ // var noderedis = require('redis');

var Redis = require('./');
var redis = new Redis({ connectTimeout: 10 });
// var redis = new Redis();
// var redis = new Redis({ connectTimeout: 10 });
// // var redis = new Redis();
redis.blpop('que1', 0, function () {
console.log(arguments);
});
// redis.blpop('que1', 0, function () {
// console.log(arguments);
// });

@@ -46,12 +46,12 @@ // redis.blpop('que1', 'que2', 10, function(){console.log('blpop', arguments)});

// var cluster = new Redis.Cluster([{
// port: 6380,
// host: '127.0.0.1'
// }, {
// port: 6381,
// host: '127.0.0.1'
// }]);
// cluster.get('foo', function (err, res) {
// console.log(err, res);
// });
var cluster = new Redis.Cluster([{
port: 6380,
host: '127.0.0.1'
}, {
port: 6381,
host: '127.0.0.1'
}]);
cluster.object('encoding', 'foo', function (err, res) {
console.log(err, res);
});
// var redis = new Redis(6388, '177.22.22.2', {

@@ -58,0 +58,0 @@ // enableReadyCheck: false

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc