Permalink
Browse files

added debug() instrumentation

  • Loading branch information...
1 parent 325881f commit 3b911acd7eb0a7b184d901b812bd0c7fcb50e378 @tj committed Mar 23, 2012
Showing with 10 additions and 3 deletions.
  1. +10 −3 lib/connect-redis.js
View
@@ -9,7 +9,8 @@
* Module dependencies.
*/
-var redis = require('redis');
+var redis = require('redis')
+ , debug = require('debug')('connect:redis');
/**
* One day in seconds.
@@ -81,10 +82,13 @@ module.exports = function(connect){
RedisStore.prototype.get = function(sid, fn){
sid = this.prefix + sid;
+ debug('GET "%s"', sid);
this.client.get(sid, function(err, data){
try {
if (!data) return fn();
- fn(null, JSON.parse(data.toString()));
+ data = data.toString();
+ debug('GOT %s', data);
+ fn(null, JSON.parse(data));
} catch (err) {
fn(err);
}
@@ -108,7 +112,10 @@ module.exports = function(connect){
? maxAge / 1000 | 0
: oneDay
, sess = JSON.stringify(sess);
- this.client.setex(sid, ttl, sess, function(){
+
+ debug('SETEX "%s" ttl:%s %s', sid, sess);
+ this.client.setex(sid, ttl, sess, function(err){
+ err || debug('SETEX complete');
fn && fn.apply(this, arguments);
});
} catch (err) {

0 comments on commit 3b911ac

Please sign in to comment.