From bab140c3969e53727d73c56558745918956bd07b Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sun, 11 May 2014 10:31:32 -0400 Subject: [PATCH] added pexpire and pexpireAt methods for redis and mongo. Added emoticons for leveldb (as per existing implementation by @psychobunny LOL) --- src/database/level/main.js | 8 ++++++++ src/database/mongo/main.js | 8 ++++++++ src/database/redis/main.js | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/database/level/main.js b/src/database/level/main.js index 9f4736de44..a147803029 100644 --- a/src/database/level/main.js +++ b/src/database/level/main.js @@ -75,4 +75,12 @@ module.exports = function(db, module) { module.expireAt = function(key, timestamp, callback) { // <__< }; + + module.pexpire = function(key, ms, callback) { + // o_o + }; + + module.pexpireAt = function(key, timestamp, callback) { + // d-_-b + }; }; \ No newline at end of file diff --git a/src/database/mongo/main.js b/src/database/mongo/main.js index 1d3d13d388..834ad4e150 100644 --- a/src/database/mongo/main.js +++ b/src/database/mongo/main.js @@ -90,4 +90,12 @@ module.exports = function(db, module) { module.expireAt = function(key, timestamp, callback) { module.setObjectField(key, 'expireAt', new Date(timestamp * 1000), callback); }; + + module.pexpire = function(key, ms, callback) { + module.expireAt(key, Date.now() + parseInt(ms, 10), callback); + }; + + module.pexpireAt = function(key, timestamp, callback) { + module.setObjectField(key, 'expireAt', new Date(timestamp), callback); + }; }; \ No newline at end of file diff --git a/src/database/redis/main.js b/src/database/redis/main.js index 4e7ec1a5f4..2525b4972f 100644 --- a/src/database/redis/main.js +++ b/src/database/redis/main.js @@ -96,4 +96,12 @@ module.exports = function(redisClient, module) { module.expireAt = function(key, timestamp, callback) { redisClient.expireat(key, timestamp, callback); }; + + module.pexpire = function(key, ms, callback) { + redisClient.pexpire(key, ms, callback); + }; + + module.expireAt = function(key, timestamp, callback) { + redisClient.pexpireat(key, timestamp, callback); + }; }; \ No newline at end of file