Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
einaros committed Sep 20, 2011
2 parents f9ea04e + 1468917 commit 1ccd8ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
8 changes: 6 additions & 2 deletions lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@ function Manager (server, options) {
this.settings[i] = options[i];
}

var self = this;

this.initStore();

this.on('set:store', function() {
self.initStore();
});

// reset listeners
this.oldListeners = server.listeners('request');
server.removeAllListeners('request');

var self = this;

server.on('request', function (req, res) {
self.handleRequest(req, res);
});
Expand Down
26 changes: 21 additions & 5 deletions lib/stores/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,28 @@ function Redis (opts) {
}
}

var redis = opts.redis || require('redis');
var redis = opts.redis || require('redis')
, RedisClient = redis.RedisClient;

// initialize a pubsub client and a regular client
this.pub = redis.createClient(opts.redisPub);
this.sub = redis.createClient(opts.redisSub);
this.cmd = redis.createClient(opts.redisClient);
if (opts.redisPub instanceof RedisClient) {
this.pub = opts.redisPub;
} else {
opts.redisPub || (opts.redisPub = {});
this.pub = redis.createClient(opts.redisPub.port, opts.redisPub.host, opts.redisPub);
}
if (opts.redisSub instanceof RedisClient) {
this.sub = opts.redisSub;
} else {
opts.redisSub || (opts.redisSub = {});
this.sub = redis.createClient(opts.redisSub.port, opts.redisSub.host, opts.redisSub);
}
if (opts.redisClient instanceof RedisClient) {
this.cmd = opts.redisClient;
} else {
opts.redisClient || (opts.redisClient = {});
this.cmd = redis.createClient(opts.redisClient.port, opts.redisClient.host, opts.redisClient);
}

Store.call(this, opts);
};
Expand Down Expand Up @@ -118,7 +134,7 @@ Redis.prototype.subscribe = function (name, consumer, fn) {
self.on('unsubscribe', function unsubscribe (ch) {
if (name == ch) {
self.sub.removeListener('message', message);
self.removeEvent('unsubscribe', unsubscribe);
self.removeListener('unsubscribe', unsubscribe);
}
});

Expand Down

0 comments on commit 1ccd8ce

Please sign in to comment.