Skip to content

Commit c290c98

Browse files
author
Maxime GUYOT
committed
return reset date
1 parent d6d2d86 commit c290c98

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/redis-store.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ var RedisStore = function(options) {
1616

1717
var setExpire = function(replies, rdskey) {
1818
// if this is new or has no expiry
19-
if (options.resetExpiryOnChange || replies[0] === 1 || replies[1] === -1) {
20-
// then expire it after the timeout
21-
options.client.pexpire(rdskey, expiryMs);
22-
}
19+
if (options.resetExpiryOnChange || replies[0] === 1 || replies[1] === -1) {
20+
// then expire it after the timeout
21+
options.client.pexpire(rdskey, expiryMs);
22+
return expiryMs;
23+
} else {
24+
return replies[1];
25+
}
2326
};
2427

2528
var processReplies = function(replies) {
@@ -47,9 +50,9 @@ var RedisStore = function(options) {
4750
}
4851

4952
replies = processReplies(replies);
50-
setExpire(replies, rdskey);
53+
var ttl = setExpire(replies, rdskey);
5154

52-
cb(null, replies[0]);
55+
cb(null, replies[0], ttl > 0 ? new Date(new Date().getTime() + ttl) : null);
5356
});
5457
};
5558

0 commit comments

Comments
 (0)