Skip to content

Commit

Permalink
Merge pull request tj#45 from rizzoma/redis-ttl-option
Browse files Browse the repository at this point in the history
Added ttl option.
  • Loading branch information
tj committed Jun 14, 2012
2 parents c4d2941 + 5a6c559 commit d3c86fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/connect-redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ module.exports = function(connect){
});
}

this.ttl = options.ttl;

if (options.db) {
var self = this;
self.client.select(options.db);
Expand Down Expand Up @@ -108,10 +110,11 @@ module.exports = function(connect){
sid = this.prefix + sid;
try {
var maxAge = sess.cookie.maxAge
, ttl = 'number' == typeof maxAge
, ttl = this.ttl
, sess = JSON.stringify(sess);
if (ttl == null) ttl = 'number' == typeof maxAge
? maxAge / 1000 | 0
: oneDay
, sess = JSON.stringify(sess);

debug('SETEX "%s" ttl:%s %s', sid, sess);
this.client.setex(sid, ttl, sess, function(err){
Expand Down

0 comments on commit d3c86fc

Please sign in to comment.