Skip to content

Commit

Permalink
Apply ioredis, and add has redis cluster condition
Browse files Browse the repository at this point in the history
  • Loading branch information
yinhewang authored and yinhewang committed Aug 6, 2018
1 parent 059476b commit 7592be7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Expand Up @@ -16,6 +16,7 @@
var EventEmitter = require('events').EventEmitter;
var debug = require('debug')('koa-redis');
var redis = require('redis');
var ioredis = require("ioredis");
var redisWrapper = require('co-redis');
var util = require('util');
var wrap = require('co-wrap-all');
Expand Down Expand Up @@ -43,7 +44,14 @@ var RedisStore = module.exports = function (options) {
options.path = options.path || options.socket || null; // For backwards compatibility
if (!options.client) {
debug('Init redis new client');
client = redis.createClient(options);
// client = redis.createClient(options);
//
// Apply ioredis, Add has redis cluster condition:
if (!options.isRedisCluster) {
client = redis.createClient(options);
} else {
client = new ioredis.Cluster(options.nodes, {redisOptions: options.redisOptions});
}
} else {
if (options.duplicate) { // Duplicate client and update with options provided
debug('Duplicating provided client with new options (if provided)');
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -24,6 +24,7 @@
"co-redis": "^2.1.1",
"co-wrap-all": "^1.0.0",
"debug": "^3.1.0",
"ioredis": "^3.2.2",
"redis": "^2.8.0"
},
"devDependencies": {
Expand Down

0 comments on commit 7592be7

Please sign in to comment.