multiple-redis
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -46,2 +46,16 @@ <a name="MultiRedisClient"></a> | ||
**Example** | ||
```js | ||
//create multiple redis clients | ||
var redis = require('redis'); | ||
var client1 = redis.createClient(...); | ||
var client2 = redis.createClient(...); | ||
//create the wrapper client | ||
var MultipleRedis = require('multiple-redis'); | ||
var multiClient = MultipleRedis.createClient([client1, client2]); | ||
//run any command on the multi client instead of the original clients | ||
multiClient.set('string key', 'string val', callback); | ||
``` | ||
<a name="MultiRedisClient.createClient"></a> | ||
@@ -60,1 +74,16 @@ ### MultiRedisClient.createClient(connectionInfo, [options]) ⇒ <code>[MultiRedisClient](#MultiRedisClient)</code> | ||
**Example** | ||
```js | ||
//create the wrapper client with connection info | ||
var MultipleRedis = require('multiple-redis'); | ||
var multiClient = MultipleRedis.createClient([{ | ||
host: 'host1', | ||
port: 6379 | ||
}, { | ||
host: 'host2', | ||
port: 6379 | ||
}], options); | ||
//run any command on the multi client instead of the original clients | ||
multiClient.set('string key', 'string val', callback); | ||
``` |
@@ -159,3 +159,17 @@ 'use strict'; | ||
* @returns {MultiRedisClient} The multiple redis client instance | ||
* @example | ||
* ```js | ||
* //create multiple redis clients | ||
* var redis = require('redis'); | ||
* var client1 = redis.createClient(...); | ||
* var client2 = redis.createClient(...); | ||
* | ||
* //create the wrapper client | ||
* var MultipleRedis = require('multiple-redis'); | ||
* var multiClient = MultipleRedis.createClient([client1, client2]); | ||
* | ||
* //run any command on the multi client instead of the original clients | ||
* multiClient.set('string key', 'string val', callback); | ||
* ``` | ||
* | ||
* @also | ||
@@ -171,2 +185,17 @@ * | ||
* @returns {MultiRedisClient} The multiple redis client instance | ||
* @example | ||
* ```js | ||
* //create the wrapper client with connection info | ||
* var MultipleRedis = require('multiple-redis'); | ||
* var multiClient = MultipleRedis.createClient([{ | ||
* host: 'host1', | ||
* port: 6379 | ||
* }, { | ||
* host: 'host2', | ||
* port: 6379 | ||
* }], options); | ||
* | ||
* //run any command on the multi client instead of the original clients | ||
* multiClient.set('string key', 'string val', callback); | ||
* ``` | ||
*/ | ||
@@ -173,0 +202,0 @@ createClient: function createClient() { |
{ | ||
"name": "multiple-redis", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Run redis commands against multiple redis instances.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -37,3 +37,3 @@ # multiple-redis | ||
<br> | ||
**This does not mean that I do not support the Redis master/slave + sentinal solution** but sometimes using multiple<br> | ||
**This does not mean that I do not support the Redis master/slave + sentinal solution** but sometimes using multiple | ||
independent Redis servers for none critical data serves as a better solution which is much more simple to deploy and manage in production. | ||
@@ -51,3 +51,3 @@ | ||
If any redis server was able to process the command, the original command callback will receive a valid response.<br> | ||
<br> | ||
This means that at least once redis server needs to work good for the main client to notify the calling code that everything works ok. | ||
@@ -66,7 +66,7 @@ <br> | ||
second redis server.<br> | ||
When the first redis server comes back up, the session is still available to the session store from the second redis server and<br> | ||
When the first redis server comes back up, the session is still available to the session store from the second redis server and | ||
any session modification (due to some HTTP request) will cause both redis servers to now hold the latest express session data. | ||
<br> | ||
It is by no means, not a perfect solution, but it does has its advantages.<br> | ||
First and formost, its simple deployment. | ||
First and foremost, its simple deployment requirements. | ||
@@ -79,3 +79,3 @@ <a name="usage"></a> | ||
//create multiple redis clients | ||
var Redis = require('redis'); | ||
var redis = require('redis'); | ||
var client1 = redis.createClient(...); | ||
@@ -89,3 +89,3 @@ var client2 = redis.createClient(...); | ||
//run any command on the multi client instead of the original clients | ||
multiClient.set("string key", "string val", callback); | ||
multiClient.set('string key', 'string val', callback); | ||
``` | ||
@@ -99,6 +99,6 @@ | ||
var multiClient = MultipleRedis.createClient([{ | ||
host: host1, | ||
host: 'host1', | ||
port: 6379 | ||
}, { | ||
host: host2, | ||
host: 'host2', | ||
port: 6379 | ||
@@ -108,5 +108,6 @@ }], options); | ||
//run any command on the multi client instead of the original clients | ||
multiClient.set("string key", "string val", callback); | ||
multiClient.set('string key', 'string val', callback); | ||
``` | ||
The rest of the API is the same as defined in the redis node library. | ||
<br> | ||
<a name="installation"></a> | ||
@@ -133,3 +134,3 @@ ## Installation | ||
| ----------- | ------- | ----------- | | ||
| 2015-09-03 | v0.0.1 | Initial release. | | ||
| 2015-09-03 | v0.0.2 | Initial release. | | ||
@@ -136,0 +137,0 @@ <a name="license"></a> |
61205
957
132