From 380ba96a8b55a6d213f279016bc107fb770d1782 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 5 Apr 2022 11:21:24 +0100 Subject: [PATCH] Merge pull request #7360 from overleaf/ho-purge-sess-improvements improve the purge sessions script a bit GitOrigin-RevId: 3b211c1377bc6aa117d3f872a829bb87b16fd9e5 --- services/web/scripts/purge_non_logged_in_sessions.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/web/scripts/purge_non_logged_in_sessions.js b/services/web/scripts/purge_non_logged_in_sessions.js index 5a3e8103c5..ef58284586 100644 --- a/services/web/scripts/purge_non_logged_in_sessions.js +++ b/services/web/scripts/purge_non_logged_in_sessions.js @@ -17,6 +17,9 @@ const queue = async.queue(function (sessKey, callback) { } else { redis.del(sessKey, () => { totalDeletedSessions++ + if (totalDeletedSessions % 1000 === 0) { + console.log(`Keys deleted so far: ${totalDeletedSessions}`) + } cb() }) } @@ -25,18 +28,17 @@ const queue = async.queue(function (sessKey, callback) { cb() } }) -}, 10) +}, 20) function scanAndPurge(cb) { const stream = redis.scanStream({ match: 'sess:*', - count: 100, + count: 1000, }) console.log('starting scan') stream.on('data', resultKeys => { console.log(`Keys found, count:${resultKeys.length}`) - console.log(`Keys deleted so far: ${totalDeletedSessions}`) queue.push(resultKeys) })