Merge pull request #7360 from overleaf/ho-purge-sess-improvements

improve the purge sessions script a bit

GitOrigin-RevId: 3b211c1377bc6aa117d3f872a829bb87b16fd9e5
This commit is contained in:
Henry Oswald 2022-04-05 11:21:24 +01:00 committed by Copybot
parent 35538da3fa
commit 380ba96a8b

View file

@ -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)
})