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.11 to 1.0.12

.jshintrc

247

API.md

@@ -1,81 +0,49 @@

#Index
**Classes**
* [class: Redis](#Redis)
* [new Redis([port], [host], [options])](#new_Redis)
* [~~Redis.createClient()~~](#Redis.createClient)
* [redis.connect()](#Redis#connect)
* [redis.disconnect()](#Redis#disconnect)
* [~~redis.end()~~](#Redis#end)
* [redis.duplicate()](#Redis#duplicate)
* [redis.monitor([callback])](#Redis#monitor)
* [class: RedisCluster](#RedisCluster)
* [new RedisCluster(startupNodes, options)](#new_RedisCluster)
* [redisCluster.disconnect()](#RedisCluster#disconnect)
## Classes
<dl>
<dt><a href="#Redis">Redis</a> ⇐ <code>[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)</code></dt>
<dd></dd>
<dt><a href="#RedisCluster">RedisCluster</a> ⇐ <code>[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)</code></dt>
<dd></dd>
<dt><a href="#Commander">Commander</a></dt>
<dd></dd>
</dl>
<a name="Redis"></a>
#class: Redis
**Extends**: `[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)`
**Members**
## Redis ⇐ <code>[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)</code>
**Kind**: global class
**Extends:** <code>[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)</code>, <code>[Commander](#Commander)</code>
* [class: Redis](#Redis)
* [new Redis([port], [host], [options])](#new_Redis)
* [~~Redis.createClient()~~](#Redis.createClient)
* [redis.connect()](#Redis#connect)
* [redis.disconnect()](#Redis#disconnect)
* [~~redis.end()~~](#Redis#end)
* [redis.duplicate()](#Redis#duplicate)
* [redis.monitor([callback])](#Redis#monitor)
* [Redis](#Redis) ⇐ <code>[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)</code>
* [new Redis([port], [host], [options])](#new_Redis_new)
* _instance_
* [.connect()](#Redis#connect)
* [.disconnect()](#Redis#disconnect)
* ~~[.end()](#Redis#end)~~
* [.duplicate()](#Redis#duplicate)
* [.monitor([callback])](#Redis#monitor)
* [.defineCommand(name, definition)](#Commander#defineCommand)
* _static_
* ~~[.createClient()](#Redis.createClient)~~
<a name="new_Redis"></a>
##new Redis([port], [host], [options])
<a name="new_Redis_new"></a>
### new Redis([port], [host], [options])
Creates a Redis instance
**Params**
- \[port=6379\] `number` | `string` | `Object` - Port of the Redis server,
or a URL string(see the examples below),
or the `options` object(see the third argument).
- \[host=localhost\] `string` | `Object` - Host of the Redis server,
when the first argument is a URL string,
this argument is an object represents the options.
- \[options\] `Object` - Other options.
- \[port=6379\] `number` - Port of the Redis server.
- \[host=localhost\] `string` - Host of the Redis server.
- \[family=4\] `string` - Version of IP stack. Defaults to 4.
- \[path=null\] `string` - Local domain socket path. If set the `port`, `host`
and `family` will be ignored.
- \[auth=null\] `string` - If set, client will send AUTH command
with the value of this option when connected.
- \[enableReadyCheck=true\] `boolean` - When a connection is established to
the Redis server, the server might still be loading the database from disk.
While loading, the server not respond to any commands.
To work around this, when this option is `true`,
ioredis will check the status of the Redis server,
and when the Redis server is able to process commands,
a `ready` event will be emitted.
- \[enableOfflineQueue=true\] `boolean` - By default,
if there is no active connection to the Redis server,
commands are added to a queue and are executed once the connection is "ready"
(when `enableReadyCheck` is `true`,
"ready" means the Redis server has loaded the database from disk, otherwise means the connection
to the Redis server has been established). If this option is false,
when execute the command when the connection isn't ready, an error will be returned.
- \[connectTimeout=10000\] `number` - The milliseconds before a timeout occurs during the initial connection to the Redis server.
- \[autoResubscribe=true\] `boolean` - After reconnected, if the previous connection was in the subscriber mode, client will auto re-subscribe these channels.
- \[lazyConnect=false\] `boolean` - By default,
When a new `Redis` instance is created, it will connect to Redis server automatically.
If you want to keep disconnected util a command is called, you can pass the `lazyConnect` option to
the constructor:
```javascript
var redis = new Redis({ lazyConnect: true });
// No attempting to connect to the Redis server here.
// Now let's connect to the Redis server
redis.get('foo', function () {
});
```
- \[retryStrategy\] `function` - See "Quick Start" section
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [port] | <code>number</code> &#124; <code>string</code> &#124; <code>Object</code> | <code>6379</code> | Port of the Redis server, or a URL string(see the examples below), or the `options` object(see the third argument). |
| [host] | <code>string</code> &#124; <code>Object</code> | <code>&quot;localhost&quot;</code> | Host of the Redis server, when the first argument is a URL string, this argument is an object represents the options. |
| [options] | <code>Object</code> | | Other options. |
| [options.port] | <code>number</code> | <code>6379</code> | Port of the Redis server. |
| [options.host] | <code>string</code> | <code>&quot;localhost&quot;</code> | Host of the Redis server. |
| [options.family] | <code>string</code> | <code>4</code> | Version of IP stack. Defaults to 4. |
| [options.path] | <code>string</code> | <code>null</code> | Local domain socket path. If set the `port`, `host` and `family` will be ignored. |
| [options.auth] | <code>string</code> | <code>null</code> | If set, client will send AUTH command with the value of this option when connected. |
| [options.enableReadyCheck] | <code>boolean</code> | <code>true</code> | When a connection is established to the Redis server, the server might still be loading the database from disk. While loading, the server not respond to any commands. To work around this, when this option is `true`, ioredis will check the status of the Redis server, and when the Redis server is able to process commands, a `ready` event will be emitted. |
| [options.enableOfflineQueue] | <code>boolean</code> | <code>true</code> | By default, if there is no active connection to the Redis server, commands are added to a queue and are executed once the connection is "ready" (when `enableReadyCheck` is `true`, "ready" means the Redis server has loaded the database from disk, otherwise means the connection to the Redis server has been established). If this option is false, when execute the command when the connection isn't ready, an error will be returned. |
| [options.connectTimeout] | <code>number</code> | <code>10000</code> | The milliseconds before a timeout occurs during the initial connection to the Redis server. |
| [options.autoResubscribe] | <code>boolean</code> | <code>true</code> | After reconnected, if the previous connection was in the subscriber mode, client will auto re-subscribe these channels. |
| [options.lazyConnect] | <code>boolean</code> | <code>false</code> | By default, When a new `Redis` instance is created, it will connect to Redis server automatically. If you want to keep disconnected util a command is called, you can pass the `lazyConnect` option to the constructor: ```javascript var redis = new Redis({ lazyConnect: true }); // No attempting to connect to the Redis server here. // Now let's connect to the Redis server redis.get('foo', function () { }); ``` |
| [options.retryStrategy] | <code>function</code> | | See "Quick Start" section |
**Extends**: `[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)`
**Example**

@@ -96,15 +64,11 @@ ```js

```
<a name="Redis.createClient"></a>
##~~Redis.createClient()~~
Create a Redis instance
***Deprecated***
<a name="Redis#connect"></a>
##redis.connect()
### redis.connect()
Create a connection to Redis.
This method will be invoked automatically when creating a new Redis instance.
**Kind**: instance method of <code>[Redis](#Redis)</code>
**Access:** public
<a name="Redis#disconnect"></a>
##redis.disconnect()
### redis.disconnect()
Disconnect from Redis.

@@ -116,11 +80,17 @@

**Kind**: instance method of <code>[Redis](#Redis)</code>
**Access:** public
<a name="Redis#end"></a>
##~~redis.end()~~
### ~~redis.end()~~
***Deprecated***
Disconnect from Redis.
***Deprecated***
**Kind**: instance method of <code>[Redis](#Redis)</code>
<a name="Redis#duplicate"></a>
##redis.duplicate()
### redis.duplicate()
Create a new instance, using the same options.
**Kind**: instance method of <code>[Redis](#Redis)</code>
**Access:** public
**Example**

@@ -131,5 +101,4 @@ ```js

```
<a name="Redis#monitor"></a>
##redis.monitor([callback])
### redis.monitor([callback])
Listen for all requests received by the server in real time.

@@ -141,5 +110,8 @@

**Params**
**Kind**: instance method of <code>[Redis](#Redis)</code>
**Access:** public
- \[callback\] `function` - The callback function. If omit, a promise will be returned.
| Param | Type | Description |
| --- | --- | --- |
| [callback] | <code>function</code> | The callback function. If omit, a promise will be returned. |

@@ -163,30 +135,93 @@ **Example**

```
<a name="Commander#defineCommand"></a>
### redis.defineCommand(name, definition)
Define a custom command using lua script
**Kind**: instance method of <code>[Redis](#Redis)</code>
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | <code>string</code> | | the command name |
| definition | <code>object</code> | | |
| definition.lua | <code>string</code> | | the lua code |
| [definition.numberOfKeys] | <code>number</code> | <code></code> | the number of keys. If omit, you have to pass the number of keys as the first argument every time you invoke the command |
<a name="Redis.createClient"></a>
### ~~Redis.createClient()~~
***Deprecated***
Create a Redis instance
**Kind**: static method of <code>[Redis](#Redis)</code>
<a name="RedisCluster"></a>
#class: RedisCluster
**Extends**: `[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)`
**Members**
## RedisCluster ⇐ <code>[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)</code>
**Kind**: global class
**Extends:** <code>[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)</code>, <code>[Commander](#Commander)</code>
* [class: RedisCluster](#RedisCluster)
* [new RedisCluster(startupNodes, options)](#new_RedisCluster)
* [redisCluster.disconnect()](#RedisCluster#disconnect)
* [RedisCluster](#RedisCluster) ⇐ <code>[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)</code>
* [new RedisCluster(startupNodes, options)](#new_RedisCluster_new)
* [.disconnect()](#RedisCluster#disconnect)
* [.defineCommand(name, definition)](#Commander#defineCommand)
<a name="new_RedisCluster"></a>
##new RedisCluster(startupNodes, options)
<a name="new_RedisCluster_new"></a>
### new RedisCluster(startupNodes, options)
Creates a Redis instance
**Params**
- startupNodes `Array.<Object>` - An array of nodes in the cluster, [{ port: number, host: string }]
- options `Object`
- \[enableOfflineQueue=true\] `boolean` - See Redis class
- \[lazyConnect=true\] `boolean` - See Redis class
- \[refreshAfterFails=10\] `number` - When a MOVED error is returned, it's considered
a failure. When the times of failures reach `refreshAfterFails`, client will call CLUSTER SLOTS
command to refresh the slots.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| startupNodes | <code>Array.&lt;Object&gt;</code> | | An array of nodes in the cluster, [{ port: number, host: string }] |
| options | <code>Object</code> | | |
| [options.enableOfflineQueue] | <code>boolean</code> | <code>true</code> | See Redis class |
| [options.lazyConnect] | <code>boolean</code> | <code>true</code> | See Redis class |
| [options.refreshAfterFails] | <code>number</code> | <code>10</code> | When a MOVED error is returned, it's considered a failure. When the times of failures reach `refreshAfterFails`, client will call CLUSTER SLOTS command to refresh the slots. |
**Extends**: `[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)`
<a name="RedisCluster#disconnect"></a>
##redisCluster.disconnect()
### redisCluster.disconnect()
Disconnect from every node in the cluster.
**Kind**: instance method of <code>[RedisCluster](#RedisCluster)</code>
**Access:** public
<a name="Commander#defineCommand"></a>
### redisCluster.defineCommand(name, definition)
Define a custom command using lua script
**Kind**: instance method of <code>[RedisCluster](#RedisCluster)</code>
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | <code>string</code> | | the command name |
| definition | <code>object</code> | | |
| definition.lua | <code>string</code> | | the lua code |
| [definition.numberOfKeys] | <code>number</code> | <code></code> | the number of keys. If omit, you have to pass the number of keys as the first argument every time you invoke the command |
<a name="Commander"></a>
## Commander
**Kind**: global class
* [Commander](#Commander)
* [new Commander()](#new_Commander_new)
* [.defineCommand(name, definition)](#Commander#defineCommand)
<a name="new_Commander_new"></a>
### new Commander()
Commander
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [options.showFriendlyErrorStack] | <code>boolean</code> | <code>false</code> | Whether to show a friendly error stack. Will decrease the performance significantly. |
<a name="Commander#defineCommand"></a>
### commander.defineCommand(name, definition)
Define a custom command using lua script
**Kind**: instance method of <code>[Commander](#Commander)</code>
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| name | <code>string</code> | | the command name |
| definition | <code>object</code> | | |
| definition.lua | <code>string</code> | | the lua code |
| [definition.numberOfKeys] | <code>number</code> | <code></code> | the number of keys. If omit, you have to pass the number of keys as the first argument every time you invoke the command |
## Changelog
### Master Branch
### v1.0.12 - April 27, 2015
* [ADD] Support for defining custom commands in Cluster.
* [PERFORMANCE] Use native array instead of fastqueue.
### v1.0.11 - April 26, 2015
* [ADD] Option of `showFriendlyErrorStack` for outputing friendly error stack.
### v1.0.10 - April 25, 2015
* [UPDATE] Improve performance for calculating slots.
* [PERFORMANCE] Improve performance for calculating slots.

@@ -7,0 +18,0 @@ ### v1.0.9 - April 25, 2015

@@ -0,1 +1,3 @@

'use strict';
var Promise = require('bluebird');

@@ -13,11 +15,6 @@ var Command = require('./command');

// 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];
}
}
this.keys = this.getKeys();
// Use the first key to calc slot
var key = this.keys[0];
if (key) {

@@ -36,2 +33,31 @@ this.slot = utils.calcSlot(key);

ClusterCommand.prototype.getKeys = function () {
var keys = [];
var i, keyStart, keyStop;
var def = commands[this.name];
if (def) {
switch (this.name) {
case 'eval':
case 'evalsha':
keyStop = parseInt(this.args[1], 10) + 2;
for (i = 2; i < keyStop; ++i) {
keys.push(this.args[i]);
}
break;
// TODO
// case 'sort':
// case 'zunionstore':
// case 'zinterstore':
default:
keyStart = def.keyStart - 1;
keyStop = def.keyStop > 0 ? def.keyStop : this.args.length + def.keyStop + 1;
for (i = keyStart; i < keyStop; i += def.step) {
keys.push(this.args[i]);
}
break;
}
}
return keys;
};
module.exports = ClusterCommand;

@@ -0,1 +1,3 @@

'use strict';
var _ = require('lodash');

@@ -2,0 +4,0 @@ var Promise = require('bluebird');

@@ -0,4 +1,13 @@

'use strict';
var _ = require('lodash');
var Command = require('./command');
var Script = require('./script');
/**
* Commander
*
* @param {boolean} [options.showFriendlyErrorStack=false] - Whether to show a friendly error stack. Will decrease the performance significantly.
* @constructor
*/
function Commander() {

@@ -8,2 +17,3 @@ this.options = _.defaults(this.options || {}, {

});
this.scriptsSet = {};
}

@@ -88,4 +98,50 @@

/**
* Define a custom command using lua script
*
* @param {string} name - the command name
* @param {object} definition
* @param {string} definition.lua - the lua code
* @param {number} [definition.numberOfKeys=null] - the number of keys.
* If omit, you have to pass the number of keys as the first argument every time you invoke the command
*/
Commander.prototype.defineCommand = function (name, definition) {
var script = new Script(definition.lua, definition.numberOfKeys);
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);
};
};
Commander.prototype.sendCommand = function () {};
module.exports = Commander;

@@ -0,1 +1,3 @@

'use strict';
var events = require('events');

@@ -2,0 +4,0 @@ var util = require('util');

@@ -0,1 +1,3 @@

'use strict';
var events = require('events');

@@ -2,0 +4,0 @@ var util = require('util');

@@ -0,1 +1,3 @@

'use strict';
var _ = require('lodash');

@@ -2,0 +4,0 @@ var Command = require('./command');

@@ -0,1 +1,3 @@

'use strict';
var Redis = require('./redis');

@@ -9,3 +11,2 @@ var utils = require('./utils');

var Commander = require('./commander');
var Queue = require('fastqueue');

@@ -24,2 +25,3 @@ /**

* @extends [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)
* @extends Commander
*/

@@ -41,3 +43,3 @@ function RedisCluster (startupNodes, options) {

this.status = 'disconnected';
this.offlineQueue = new Queue();
this.offlineQueue = [];

@@ -55,2 +57,3 @@ this.initializeSlotsCache();

enableOfflineQueue: true,
enableReadyCheck: true,
refreshAfterFails: 10,

@@ -81,2 +84,3 @@ lazyConnect: true

host: host,
enableReadyCheck: this.options.enableReadyCheck,
lazyConnect: this.options.lazyConnect

@@ -125,3 +129,2 @@ });

}
this.offlineQueue = new Queue();
};

@@ -133,3 +136,3 @@

var offlineQueue = this.offlineQueue;
this.offlineQueue = new Queue();
this.offlineQueue = [];
while (offlineQueue.length > 0) {

@@ -139,3 +142,2 @@ var command = offlineQueue.shift();

}
offlineQueue = null;
}

@@ -160,2 +162,3 @@ };

if (errv[0] === 'MOVED') {
debug('command %s is moved to %s:%s', command.name, hostPort[0], hostPort[1]);
_this.slots[errv[1]] = node;

@@ -168,2 +171,3 @@ tryConnection();

} else {
debug('command %s is required to ask %s:%s', command.name, hostPort[0], hostPort[1]);
tryConnection(false, node);

@@ -170,0 +174,0 @@ }

@@ -0,1 +1,3 @@

'use strict';
var _ = require('lodash');

@@ -8,6 +10,4 @@ var util = require('util');

var Pipeline = require('./pipeline');
var Queue = require('fastqueue');
var Command = require('./command');
var Commander = require('./commander');
var Script = require('./script');
var utils = require('./utils');

@@ -66,2 +66,3 @@ var eventHandler = require('./redis/event_handler');

* @extends [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)
* @extends Commander
* @example

@@ -139,5 +140,4 @@ * ```js

this.commandQueue = new Queue();
this.offlineQueue = new Queue();
this.scriptsSet = {};
this.commandQueue = [];
this.offlineQueue = [];

@@ -312,3 +312,2 @@ if (this.options.sentinels) {

}
this.offlineQueue = new Queue();

@@ -320,3 +319,2 @@ var command;

}
this.commandQueue = new Queue();
};

@@ -378,38 +376,2 @@

Redis.prototype.defineCommand = function (name, definition) {
var script = new Script(definition.lua, definition.numberOfKeys);
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);
};
};
/**

@@ -416,0 +378,0 @@ * Listen for all requests received by the server in real time.

@@ -1,3 +0,3 @@

var Queue = require('fastqueue');
var Command = require('../command');
'use strict';
var debug = require('debug')('ioredis:connection');

@@ -11,3 +11,3 @@

self.commandQueue = new Queue();
self.commandQueue = [];

@@ -122,3 +122,3 @@ // AUTH command should be processed before any other commands

var offlineQueue = self.offlineQueue;
self.offlineQueue = new Queue();
self.offlineQueue = [];
while (offlineQueue.length > 0) {

@@ -131,4 +131,2 @@ var item = offlineQueue.shift();

}
// TODO: hmm...
offlineQueue = null;
}

@@ -135,0 +133,0 @@ if (self.condition.select !== finalSelect) {

@@ -0,4 +1,4 @@

'use strict';
var _ = require('lodash');
var Queue = require('fastqueue');
var utils = require('../../utils');
var Command = require('../../command');

@@ -37,6 +37,2 @@ var SubscriptionSet = require('../../subscription_set');

if (this.commandQueue.length === 0) {
this.commandQueue = new Queue();
}
err.command = {

@@ -103,3 +99,3 @@ name: command.name,

this.condition.mode.subscriber.add(replyType, channel);
command = shiftCommand.call(this);
command = shiftCommand(this);
if (!fillSubCommand(command, reply[2])) {

@@ -119,3 +115,3 @@ this.commandQueue.unshift(command);

}
command = shiftCommand.call(this);
command = shiftCommand(this);
if (!fillUnsubCommand(command, count)) {

@@ -126,7 +122,7 @@ this.commandQueue.unshift(command);

default:
command = shiftCommand.call(this);
command = shiftCommand(this);
command.resolve(reply);
}
} else {
command = shiftCommand.call(this);
command = shiftCommand(this);
if (!command) {

@@ -151,7 +147,4 @@ return this.emit('error', new Error('Command queue state error. If you can reproduce this, please report it.'));

function shiftCommand() {
var command = this.commandQueue.shift();
if (this.commandQueue.length === 0) {
this.commandQueue = new Queue();
}
function shiftCommand(self) {
var command = self.commandQueue.shift();
return command;

@@ -158,0 +151,0 @@ }

@@ -0,1 +1,3 @@

'use strict';
var util = require('util');

@@ -2,0 +4,0 @@

@@ -0,1 +1,3 @@

'use strict';
var Command = require('./command');

@@ -2,0 +4,0 @@ var crypto = require('crypto');

@@ -0,1 +1,3 @@

'use strict';
var util = require('util');

@@ -2,0 +4,0 @@ var utils = require('./utils');

@@ -0,1 +1,3 @@

'use strict';
/**

@@ -2,0 +4,0 @@ * Tiny class to simplify dealing with subscription set

@@ -0,1 +1,3 @@

'use strict';
/*

@@ -2,0 +4,0 @@ * Copyright 2001-2010 Georges Menie (www.menie.org)

@@ -0,1 +1,3 @@

'use strict';
/**

@@ -2,0 +4,0 @@ * Test if two buffers are equal

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

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

"test:cov": "NODE_ENV=test node ./node_modules/istanbul/lib/cli.js cover --preserve-comments ./node_modules/mocha/bin/_mocha -- -R spec",
"generate-docs": "jsdoc2md lib/redis.js lib/redis_cluster.js > API.md",
"generate-docs": "jsdoc2md lib/redis.js lib/redis_cluster.js lib/commander.js > API.md",
"bench": "matcha benchmark.js"

@@ -30,3 +30,2 @@ },

"debug": "^2.1.3",
"fastqueue": "^0.1.0",
"flexbuffer": "0.0.6",

@@ -41,5 +40,5 @@ "ioredis-commands": "4.0.0",

"jsdoc": "^3.3.0-beta3",
"jsdoc-to-markdown": "^1.0.3",
"matcha": "^0.6.0",
"mocha": "^2.2.1",
"server-destroy": "^1.0.0",
"sinon": "^1.14.1"

@@ -46,0 +45,0 @@ },

@@ -435,3 +435,3 @@ # ioredis

but a few so that if one is down the client will try the next one, and the client will discover other nodes automatically when at least one node is connnected.
0. Some features are not available in the cluster mode, e.g. `pipeline` and custom commands(currently).
0. Pipelining is not available in the cluster currently.

@@ -438,0 +438,0 @@ ## hiredis

@@ -0,1 +1,2 @@

'use strict';
// var noderedis = require('redis');

@@ -7,9 +8,9 @@ // var client = noderedis.createClient();

var Redis = require('./');
var redis = new Redis({ showFriendlyErrorStack: 10 });
// var redis = new Redis({ showFriendlyErrorStack: 10 });
// var redis = new Redis();
Redis.Promise.onPossiblyUnhandledRejection(function(error){
console.log(error);
});
// Redis.Promise.onPossiblyUnhandledRejection(function(error){
// console.log(error);
// });
redis.set('foo');
// redis.set('foo');
// var redis = new Redis();

@@ -52,12 +53,18 @@

// var cluster = new Redis.Cluster([{
// port: 6380,
// host: '127.0.0.1'
// }, {
// port: 6381,
// host: '127.0.0.1'
// }]);
// cluster.mget('foo13', '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.defineCommand('testGet', {
numberOfKeys: 1,
lua: 'return redis.call("mget", KEYS[1], ARGV[1])'
});
cluster.testGet('foo', '{foo}2', function (err, res) {
console.log(err, res);
});
// var redis = new Redis(6388, '177.22.22.2', {

@@ -64,0 +71,0 @@ // enableReadyCheck: false

@@ -0,1 +1,3 @@

'use strict';
describe('auth', function () {

@@ -2,0 +4,0 @@ it('should send auth before other commands', function (done) {

@@ -0,1 +1,3 @@

'use strict';
var utils = require('../../lib/utils');

@@ -2,0 +4,0 @@

@@ -0,1 +1,3 @@

'use strict';
describe('connection', function () {

@@ -20,3 +22,3 @@ it('should emit "connect" when connected', function (done) {

var times = 0;
var sendCommand = stub(redis, 'sendCommand', function (command) {
stub(redis, 'sendCommand', function (command) {
times += 1;

@@ -23,0 +25,0 @@ if (times === 1) {

@@ -0,5 +1,7 @@

'use strict';
describe('lazy connect', function () {
it('should not call `connect` when init', function () {
stub(Redis.prototype, 'connect').throws(new Error('`connect` should not be called'));
var redis = new Redis({ lazyConnect: true });
new Redis({ lazyConnect: true });
Redis.prototype.connect.restore();

@@ -6,0 +8,0 @@ });

@@ -0,1 +1,3 @@

'use strict';
describe('pipeline', function () {

@@ -2,0 +4,0 @@ it('should return correct result', function (done) {

@@ -0,1 +1,3 @@

'use strict';
describe('pub/sub', function () {

@@ -2,0 +4,0 @@ it('should invoke the callback when subscribe successfully', function (done) {

@@ -1,2 +0,2 @@

var Command = require('../../lib/command');
'use strict';

@@ -3,0 +3,0 @@ describe('scripting', function () {

@@ -0,1 +1,3 @@

'use strict';
describe('select', function () {

@@ -2,0 +4,0 @@ it('should support auto select', function (done) {

@@ -0,1 +1,3 @@

'use strict';
describe('send command', function () {

@@ -2,0 +4,0 @@ it('should support callback', function (done) {

@@ -0,1 +1,3 @@

'use strict';
describe('sentinel', function () {

@@ -2,0 +4,0 @@ describe('connect', function () {

@@ -0,1 +1,3 @@

'use strict';
describe('showFriendlyErrorStack', function () {

@@ -2,0 +4,0 @@ it('should show friendly error stack', function (done) {

@@ -0,1 +1,3 @@

'use strict';
describe('transaction', function () {

@@ -2,0 +4,0 @@ it('should works like pipeline by default', function (done) {

@@ -0,1 +1,3 @@

'use strict';
describe('transformer', function () {

@@ -2,0 +4,0 @@ describe('default transformer', function () {

@@ -0,1 +1,3 @@

'use strict';
GLOBAL.expect = require('chai').expect;

@@ -6,3 +8,3 @@

var Redis = GLOBAL.Redis = require('../..');
GLOBAL.Redis = require('../..');
GLOBAL.MockServer = require('./mock_server');

@@ -9,0 +11,0 @@

@@ -0,1 +1,3 @@

'use strict';
var Command = require('../../lib/command');

@@ -2,0 +4,0 @@

@@ -0,1 +1,3 @@

'use strict';
var Commander = require('../../lib/commander');

@@ -2,0 +4,0 @@

@@ -0,1 +1,3 @@

'use strict';
['javascript', 'hiredis'].forEach(function (type) {

@@ -2,0 +4,0 @@ var Parser;

@@ -0,1 +1,3 @@

'use strict';
describe('Redis', function () {

@@ -2,0 +4,0 @@ describe('constructor', function () {

@@ -0,1 +1,3 @@

'use strict';
var utils = require('../../lib/utils');

@@ -2,0 +4,0 @@ describe('utils', function () {

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