# 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 FROM nopaste WHERE uuid = %s", uuid)
+ 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
- self.memcache.set("nopaste-%s" % uuid, content, 6 * 3600)
+ # 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)
return content