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

redis

Package Overview
Dependencies
Maintainers
7
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

.nyc_output/24702.json

8

changelog.md
Changelog
=========
## v.2.3.1 - xx Nov, 2015
Bugfixes
- Fixed saving buffers with charsets other than utf-8 while using multi ([@BridgeAR](https://github.com/BridgeAR))
- Fixed js parser handling big values very slow ([@BridgeAR](https://github.com/BridgeAR))
- The speed is up to ~500% faster than before but still up to ~50% slower than the hiredis parser.
## v.2.3.0 - 30 Oct, 2015

@@ -5,0 +13,0 @@

54

index.js

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

this.stream.on('data', function (buffer_from_socket) {
// The data.toString() has a significant impact on big chunks and therefor this should only be used if necessary
debug('Net read ' + this.address + ' id ' + this.connection_id); // + ': ' + data.toString());
// The buffer_from_socket.toString() has a significant impact on big chunks and therefor this should only be used if necessary
debug('Net read ' + self.address + ' id ' + self.connection_id); // + ': ' + buffer_from_socket.toString());
self.reply_parser.execute(buffer_from_socket);

@@ -735,8 +735,16 @@ });

buffer_args = true;
if (this.pipeline !== 0) {
this.pipeline += 2;
this.writeDefault = this.writeBuffers;
}
} else if (typeof args[i] !== 'string') {
arg = String(arg);
// 30000 seemed to be a good value to switch to buffers after testing this with and checking the pros and cons
args[i] = String(args[i]);
// 30000 seemed to be a good value to switch to buffers after testing and checking the pros and cons
} else if (args[i].length > 30000) {
big_data = true;
args[i] = new Buffer(args[i]);
if (this.pipeline !== 0) {
this.pipeline += 2;
this.writeDefault = this.writeBuffers;
}
}

@@ -769,3 +777,3 @@ }

// Return false to signal buffering
return false;
return !this.should_buffer;
}

@@ -792,3 +800,3 @@

for (i = 0; i < args.length; i += 1) {
arg = String(args[i]);
arg = args[i];
command_str += '$' + Buffer.byteLength(arg) + '\r\n' + arg + '\r\n';

@@ -804,4 +812,3 @@ }

arg = args[i];
if (!Buffer.isBuffer(arg)) {
arg = String(arg);
if (typeof arg === 'string') {
this.write('$' + Buffer.byteLength(arg) + '\r\n' + arg + '\r\n');

@@ -819,2 +826,18 @@ } else {

RedisClient.prototype.writeDefault = RedisClient.prototype.writeStrings = function (data) {
var command, str = '';
while (command = this.pipeline_queue.shift()) {
str += command;
}
this.should_buffer = !this.stream.write(str + data);
};
RedisClient.prototype.writeBuffers = function (data) {
var command;
while (command = this.pipeline_queue.shift()) {
this.stream.write(command);
}
this.should_buffer = !this.stream.write(data);
};
RedisClient.prototype.write = function (data) {

@@ -828,7 +851,3 @@ if (this.pipeline === 0) {

if (this.pipeline === 0) {
var command, str = '';
while (command = this.pipeline_queue.shift()) {
str += command;
}
this.should_buffer = !this.stream.write(str + data);
this.writeDefault(data);
return;

@@ -1132,6 +1151,8 @@ }

this._client.uncork();
return this._client.send_command('exec', [], function(err, replies) {
this._client.send_command('exec', [], function(err, replies) {
self.execute_callback(err, replies);
});
this._client.uncork();
this._client.writeDefault = this._client.writeStrings;
return !this._client.should_buffer;
};

@@ -1243,3 +1264,4 @@

this._client.uncork();
return this._client.should_buffer;
this._client.writeDefault = this._client.writeStrings;
return !this._client.should_buffer;
};

@@ -1246,0 +1268,0 @@

'use strict';
var util = require('util');
var util = require('util');
function JavascriptReplyParser() {
this.name = exports.name;
this._buffer = new Buffer(0);
this._offset = 0;
this._buffer = new Buffer(0);
this._offset = 0;
this._buffers = [];
}

@@ -69,3 +70,3 @@

if (packetHeader > this._bytesRemaining()) {
if (packetHeader > this._buffer.length - this._offset) {
this._offset = offset - 1;

@@ -97,10 +98,33 @@ throw new IncompleteReadBuffer('Wait for more data.');

JavascriptReplyParser.prototype.execute = function (buffer) {
this.append(buffer);
var i = buffer.length - 1;
var type, offset;
while (buffer[i] !== 0x0a) {
i--;
if (i < 1) {
this._buffers.push(buffer);
return;
}
}
if (this._buffers.length !== 0) {
this._buffers.unshift(this._offset === 0 ? this._buffer : this._buffer.slice(this._offset));
this._buffers.push(buffer);
this._buffer = Buffer.concat(this._buffers);
this._buffers = [];
} else if (this._offset >= this._buffer.length) {
this._buffer = buffer;
} else {
this._buffer = Buffer.concat([this._buffer.slice(this._offset), buffer]);
}
this._offset = 0;
this.run();
};
JavascriptReplyParser.prototype.run = function (buffer) {
var type, offset = this._offset;
while (true) {
offset = this._offset;
// at least 4 bytes: :1\r\n
if (this._bytesRemaining() < 4) {
if (this._buffer.length - this._offset < 4) {
break;

@@ -114,3 +138,3 @@ }

this.send_reply(this._parseResult(type));
} else if (type === 45) { // Errors -
} else if (type === 45) { // Errors -
this.send_error(this._parseResult(type));

@@ -136,20 +160,7 @@ } else if (type === 42) { // Arrays *

JavascriptReplyParser.prototype.append = function (newBuffer) {
// out of data
if (this._offset >= this._buffer.length) {
this._buffer = newBuffer;
this._offset = 0;
return;
}
this._buffer = Buffer.concat([this._buffer.slice(this._offset), newBuffer]);
this._offset = 0;
};
JavascriptReplyParser.prototype.parseHeader = function () {
var end = this._packetEndOffset() + 1,
value = this._buffer.toString('ascii', this._offset, end - 1) | 0;
var end = this._packetEndOffset(),
value = this._buffer.toString('ascii', this._offset, end) | 0;
this._offset = end + 1;
this._offset = end + 2;

@@ -174,7 +185,3 @@ return value;

JavascriptReplyParser.prototype._bytesRemaining = function () {
return (this._buffer.length - this._offset) < 0 ? 0 : (this._buffer.length - this._offset);
};
exports.Parser = JavascriptReplyParser;
exports.name = 'javascript';
{
"name": "redis",
"version": "2.3.0",
"version": "2.3.1",
"description": "Redis client library",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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