Commits

danjac  committed dfbe78c

selective cached

  • Participants
  • Parent commits 458b02f

Comments (0)

Files changed (1)

File newsmeme/__init__.py

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