Permalink
Browse files

Merge pull request #54 from louischatriot/master

RedisStore can have its users (e.g connect-session) handle connection to Redis problems
  • Loading branch information...
2 parents c20fa0b + 8b78de5 commit 07f98c364dda7117bca0b10ecd8911770be1939a @tj committed Sep 5, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/connect-redis.js
View
@@ -42,6 +42,8 @@ module.exports = function(connect){
*/
function RedisStore(options) {
+ var self = this;
+
options = options || {};
Store.call(this, options);
this.prefix = null == options.prefix
@@ -58,14 +60,17 @@ module.exports = function(connect){
this.ttl = options.ttl;
if (options.db) {
- var self = this;
self.client.select(options.db);
self.client.on("connect", function() {
self.client.send_anyways = true;
self.client.select(options.db);
self.client.send_anyways = false;
});
}
+
+ // Let users of the RedisStore handle connection to Redis issues if safe mode enabled
+ self.client.on('error', function () { self.emit('disconnect'); });
+ self.client.on('connect', function () { self.emit('connect'); });
};
/**

0 comments on commit 07f98c3

Please sign in to comment.