From 525235a27ef65f066378ed857fa7c05f1fb93369 Mon Sep 17 00:00:00 2001 From: Nyo Date: Sun, 20 Nov 2016 13:03:07 +0100 Subject: [PATCH] .BANCHO. Move bancho sessions to redis --- common | 2 +- objects/tokenList.py | 8 ++++++-- pep.py | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common b/common index 369415b..1dce6bc 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 369415b54e0dd8892fe557f0b7fb29c3933fc19e +Subproject commit 1dce6bc5b40fdfaca3064d5f2d23ca7dd1598256 diff --git a/objects/tokenList.py b/objects/tokenList.py index 0f90668..e7b486b 100644 --- a/objects/tokenList.py +++ b/objects/tokenList.py @@ -185,12 +185,16 @@ class tokenList: def deleteBanchoSessions(self): """ - Truncate bancho_sessions table. + Remove all `peppy:sessions:*` redis keys. Call at bancho startup to delete old cached sessions :return: """ - glob.db.execute("TRUNCATE TABLE bancho_sessions") + try: + # TODO: Make function or some redis meme + glob.redis.eval("return redis.call('del', unpack(redis.call('keys', ARGV[1])))", 0, "peppy:sessions:*") + except: + pass def tokenExists(self, username = "", userID = -1): diff --git a/pep.py b/pep.py index 763baa3..eb2ca4c 100644 --- a/pep.py +++ b/pep.py @@ -114,6 +114,7 @@ if __name__ == "__main__": # Empty redis cache try: + # TODO: Make function or some redis meme glob.redis.eval("return redis.call('del', unpack(redis.call('keys', ARGV[1])))", 0, "peppy:*") except redis.exceptions.ResponseError: # Script returns error if there are no keys starting with peppy:*