From 0037dad8f4e708906b792f230c9a000b4b1b635e Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Tue, 25 Apr 2017 10:46:39 -0400 Subject: [PATCH] AN-8701 Increase course_summaries cache timeout to 1 hour (#663) * Increase default cache timeout to 1 hour * Only increase timeout for summaries. Also sets local cache to a DummyCache. * Revert local.py DummyCache setting * Update api-client to 0.11.0 * Revert "Update api-client to 0.11.0" This reverts commit e719968954b3b82c9eb0fe65cabcb8e501a633f6. Accidentally committed to wrong branch. --- analytics_dashboard/courses/presenters/course_summaries.py | 3 ++- analytics_dashboard/settings/base.py | 4 ++++ analytics_dashboard/settings/dev.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/analytics_dashboard/courses/presenters/course_summaries.py b/analytics_dashboard/courses/presenters/course_summaries.py index f22d497a7..e374d6892 100644 --- a/analytics_dashboard/courses/presenters/course_summaries.py +++ b/analytics_dashboard/courses/presenters/course_summaries.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.core.cache import cache from courses.presenters import BasePresenter @@ -28,7 +29,7 @@ def _get_all_summaries(self): all_summaries = [ {field: ('' if val is None and field in self.NON_NULL_STRING_FIELDS else val) for field, val in summary.items()} for summary in all_summaries] - cache.set(self.CACHE_KEY, all_summaries) + cache.set(self.CACHE_KEY, all_summaries, settings.COURSE_SUMMARIES_CACHE_TIMEOUT) return all_summaries def _get_last_updated(self, summaries): diff --git a/analytics_dashboard/settings/base.py b/analytics_dashboard/settings/base.py index 8f90d27e2..6be33455e 100644 --- a/analytics_dashboard/settings/base.py +++ b/analytics_dashboard/settings/base.py @@ -480,3 +480,7 @@ # Default (None) includes all available fields, in alphabetical order. LEARNER_API_LIST_DOWNLOAD_FIELDS = None ########## END LEARNER_API_LIST_DOWNLOAD_FIELDS + +########## CACHE CONFIGURATION +COURSE_SUMMARIES_CACHE_TIMEOUT = 3600 # 1 hour timeout +########## END CACHE CONFIGURATION diff --git a/analytics_dashboard/settings/dev.py b/analytics_dashboard/settings/dev.py index e8fafce66..d54c82530 100644 --- a/analytics_dashboard/settings/dev.py +++ b/analytics_dashboard/settings/dev.py @@ -20,7 +20,7 @@ # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches CACHES = { 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache' } } ########## END CACHE CONFIGURATION