Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.3.1 to 1.3.2

6

Changelog.md

@@ -5,5 +5,9 @@ ## Changelog

### v1.3.2 - May 18, 2015
* The constructor of `pipeline`/`multi` accepts a batch of commands.
### v1.3.1 - May 16, 2015
* Improve the performance of sending commands[#35](https://github.com/luin/ioredis/issues/35). Thanks to [@AVVS](https://github.com/AVVS).
* Improve the performance of sending commands([#35](https://github.com/luin/ioredis/issues/35)). Thanks to [@AVVS](https://github.com/AVVS).

@@ -10,0 +14,0 @@ ### v1.3.0 - May 15, 2015

59

lib/commander.js

@@ -10,2 +10,4 @@ 'use strict';

*
* This is the base class of Redis, Redis.Cluster and Pipeline
*
* @param {boolean} [options.showFriendlyErrorStack=false] - Whether to show a friendly error stack. Will decrease the performance significantly.

@@ -67,33 +69,4 @@ * @constructor

this.scriptsSet[name] = script;
this[name] = function () {
var args = _.toArray(arguments);
var callback;
if (typeof args[args.length - 1] === 'function') {
callback = args.pop();
}
var options = { replyEncoding: 'utf8' };
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error().stack;
}
return script.execute(this, args, options, callback);
};
this[name + 'Buffer'] = function () {
var args = _.toArray(arguments);
var callback;
if (typeof args[args.length - 1] === 'function') {
callback = args.pop();
}
var options = { replyEncoding: null };
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error().stack;
}
return script.execute(this, args, options, callback);
};
this[name] = generateScriptingFunction(script, 'utf8');
this[name + 'Buffer'] = generateScriptingFunction(script, null);
};

@@ -146,2 +119,26 @@

function generateScriptingFunction (_script, _encoding) {
return function () {
var length = arguments.length;
var lastArgIndex = length - 1;
var callback = arguments[lastArgIndex];
if (typeof callback !== 'function') {
callback = undefined;
} else {
length = lastArgIndex;
}
var args = new Array(length);
for (var i = 0; i < length; i++) {
args[i] = arguments[i];
}
var options = { replyEncoding: _encoding };
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error().stack;
}
return _script.execute(this, args, options, callback);
};
}
module.exports = Commander;

@@ -161,2 +161,12 @@ 'use strict';

Pipeline.prototype.addBatch = function (commands) {
for (var i = 0; i < commands.length; ++i) {
var command = commands[i];
var commandName = command.shift();
this[commandName].apply(this, command);
}
return this;
};
var multi = Pipeline.prototype.multi;

@@ -163,0 +173,0 @@ Pipeline.prototype.multi = function () {

@@ -292,3 +292,3 @@ 'use strict';

/**
* Create a new instance, using the same options.
* Create a new instance with the same options as the current one.
*

@@ -295,0 +295,0 @@ * @example

@@ -7,4 +7,7 @@ 'use strict';

exports.addTransactionSupport = function (redis) {
redis.pipeline = function () {
redis.pipeline = function (commands) {
var pipeline = new Pipeline(this);
if (Array.isArray(commands)) {
pipeline.addBatch(commands);
}
return pipeline;

@@ -14,3 +17,7 @@ };

var multi = redis.multi;
redis.multi = function (options) {
redis.multi = function (commands, options) {
if (typeof options === 'undefined' && !Array.isArray(commands)) {
options = commands;
commands = null;
}
if (options && options.pipeline === false) {

@@ -21,2 +28,5 @@ return multi.call(this);

pipeline.multi();
if (Array.isArray(commands)) {
pipeline.addBatch(commands);
}
var exec = pipeline.exec;

@@ -23,0 +33,0 @@ pipeline.exec = function (callback) {

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -188,2 +188,12 @@ # ioredis

In addition to adding commands to the `pipeline` queue individually, you can also pass an array of commands and arguments to the constructor:
```javascript
redis.pipeline([
['set', 'foo', 'bar'],
['get', 'foo']
]).exec(function () { /* ... */ });
```
## Transaction

@@ -238,2 +248,11 @@ Most of the time the transaction commands `multi` & `exec` are used together with pipeline.

The constructor of `multi` also accepts a batch of commands:
```javascript
redis.multi([
['set', 'foo', 'bar'],
['get', 'foo']
]).exec(function () { /* ... */ });
```
Inline transaction is supported by pipeline, that means you can group a subset commands

@@ -513,3 +532,3 @@ in the pipeline into a transaction:

0. All keys in a pipeline should belong to the same slot since ioredis sends all commands in the pipeline to the same node. For example:
0. All keys in a pipeline should belong to the same slot since ioredis sends all commands in a pipeline to the same node.
0. You can't use `multi` without pipeline(aka `cluster.multi({ pipeline: false })`). This is because when you call `cluster.multi({ pipeline: false })`, ioredis doesn't know which node should the `multi` command be sent to.

@@ -538,3 +557,3 @@ 0. Chaining custom commands in the pipeline is not supported in Cluster mode.

redis.set('foo', function (err) {
// err instanceof Redis.ReplyError
err instanceof Redis.ReplyError
});

@@ -614,3 +633,3 @@ ```

==========================
ioredis: 1.3.0
ioredis: 1.3.1
node_redis: 0.12.1

@@ -617,0 +636,0 @@ CPU: 8

@@ -74,2 +74,20 @@ 'use strict';

});
describe('#addBatch', function () {
it('should accept commands in constructor', function (done) {
var redis = new Redis();
var pending = 1;
redis.pipeline([
['set', 'foo', 'bar'],
['get', 'foo', function (err, result) {
expect(result).to.eql('bar');
pending -= 1;
}]
]).exec(function (err, results) {
expect(pending).to.eql(0);
expect(results[1][1]).to.eql('bar');
done();
});
});
});
});

@@ -41,6 +41,5 @@ 'use strict';

}).exec(function (err, result) {
expect(pending).to.eql(0);
expect(result).to.eql([[null, 'OK'], [null, 'bar']]);
if (!pending) {
done();
}
done();
});

@@ -73,2 +72,20 @@ });

});
describe('#addBatch', function () {
it('should accept commands in constructor', function (done) {
var redis = new Redis();
var pending = 1;
redis.multi([
['set', 'foo', 'bar'],
['get', 'foo', function (err, result) {
expect(result).to.eql('QUEUED');
pending -= 1;
}]
]).exec(function (err, results) {
expect(pending).to.eql(0);
expect(results[1][1]).to.eql('bar');
done();
});
});
});
});
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