]> git.ipfire.org Git - ipfire.org.git/commitdiff
nopaste: Drop using memcache
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 11 Oct 2018 12:20:23 +0000 (13:20 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 11 Oct 2018 12:20:23 +0000 (13:20 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/nopaste.py

index fc186fa0b8ffa2719dd715574827ae13154cf097..da7d54cc38e96469d9636cc8ff1da7318eeafffe 100644 (file)
@@ -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 \