From 09fa25a825842d86f40cd2b422b35e5bfbc340f8 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Oct 2018 13:20:23 +0100 Subject: [PATCH] nopaste: Drop using memcache Signed-off-by: Michael Tremer --- src/backend/nopaste.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/backend/nopaste.py b/src/backend/nopaste.py index fc186fa0..da7d54cc 100644 --- a/src/backend/nopaste.py +++ b/src/backend/nopaste.py @@ -63,22 +63,11 @@ class Nopaste(Object): return res def get_content(self, uuid): - # Try fetching the object from memcache. If found, we return it right away. - content = self.memcache.get("nopaste-%s" % uuid) - - # If the object was not in the cache, we need to fetch it from the database. - if not content: - res = self.db.get("SELECT content, views FROM nopaste WHERE uuid = %s", uuid) - - # Convert the content to a byte string - content = "%s" % res.content - - # Save it in the cache for later when it has been requested a couple - # of times - if res.views >= 5: - self.memcache.set("nopaste-%s" % uuid, content, 6 * 3600) + res = self.db.get("SELECT content FROM nopaste \ + WHERE uuid = %s", uuid) - return content + if res: + return res.content def _update_lastseen(self, uuid): self.db.execute("UPDATE nopaste SET time_lastseen = NOW(), views = views + 1 \ -- 2.47.3