Commits

Anonymous committed a199a23

tag caching fix

Comments (0)

Files changed (1)

newsmeme/__init__.py

     
     @app.context_processor
     def get_tags():
-        tags = Tag.query.order_by(Tag.num_posts.desc()).limit(10).all()
+        tags = cache.get("tags")
+        if tags is None:
+            tags = Tag.query.order_by(Tag.num_posts.desc()).limit(10).all()
+            cache.set("tags", tags)
+
         return dict(tags=tags)
 
     @app.context_processor