Commits

Yann Malet  committed 3f23976

Add a setting to control the default timeout of the cache for the feeds

  • Participants
  • Parent commits e462462

Comments (0)

Files changed (2)

File cmsplugin_feed/cms_plugins.py

 
 from cmsplugin_feed.models import Feed
 from cmsplugin_feed.forms import FeedForm
+from cmsplugin_feed.settings import CMSPLUGIN_FEED_CACHE_TIMEOUT
 
 def get_cached_feed(instance):
     """
     """
     if not cache.has_key("feed_%s" %instance.id):
         feed = feedparser.parse(instance.feed_url)
-        cache.set("feed_%s" %instance.id, feed, 100)
+        cache.set("feed_%s" %instance.id, feed, CMSPLUGIN_FEED_CACHE_TIMEOUT)
     return cache.get("feed_%s" %instance.id)
 
 class FeedPlugin(CMSPluginBase):

File cmsplugin_feed/settings.py

+"""
+This module enforces default settings when the main settings module does not
+contain the appropriate settings.
+"""
+from django.conf import settings
+
+# Define the cache timeout in second for the feed
+# default is 3600s (1 hour)
+CMSPLUGIN_FEED_CACHE_TIMEOUT = getattr(settings,
+                                       'CMSPLUGIN_FEED_CACHE_TIMEOUT', 3600)