From 2252ab74797d482f2fc718b88af052a052365924 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 7 Sep 2014 03:17:51 -0400 Subject: [PATCH] notifications.prune run every hour dont get more than 500 notifications --- src/database/level/main.js | 4 ++++ src/database/mongo/main.js | 5 +++++ src/database/redis/main.js | 8 ++++++++ src/notifications.js | 40 +++++++++++++++++++++----------------- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/database/level/main.js b/src/database/level/main.js index 97586c33b2..00c55bb16d 100644 --- a/src/database/level/main.js +++ b/src/database/level/main.js @@ -41,6 +41,10 @@ module.exports = function(db, module) { db.del(key, callback); }; + module.deleteAll = function(keys, callback) { + async.each(keys, module.delete, callback); + }; + module.get = function(key, callback) { db.get(key, function(err, value) { callback(false, value); diff --git a/src/database/mongo/main.js b/src/database/mongo/main.js index dacce8d9f6..2382acd28e 100644 --- a/src/database/mongo/main.js +++ b/src/database/mongo/main.js @@ -74,6 +74,11 @@ module.exports = function(db, module) { db.collection('objects').remove({_key:key}, callback); }; + module.deleteAll = function(keys, callback) { + callback = callback || helpers.noop; + db.collection('objects').remove({_key: {$in: keys}}, callback); + }; + module.get = function(key, callback) { module.getObjectField(key, 'value', callback); }; diff --git a/src/database/redis/main.js b/src/database/redis/main.js index 1cf8d35f5c..986c3a7bc8 100644 --- a/src/database/redis/main.js +++ b/src/database/redis/main.js @@ -73,6 +73,14 @@ module.exports = function(redisClient, module) { redisClient.del(key, callback); }; + module.deleteAll = function(keys, callback) { + var multi = redisClient.multi(); + for(var i=0; i