diff --git a/openedx/core/djangoapps/config_model_utils/models.py b/openedx/core/djangoapps/config_model_utils/models.py index 11d4d6383a10..629fdeed8435 100644 --- a/openedx/core/djangoapps/config_model_utils/models.py +++ b/openedx/core/djangoapps/config_model_utils/models.py @@ -11,7 +11,7 @@ from enum import Enum import crum -from config_models.models import ConfigurationModel, cache +from config_models.models import ConfigurationModel from django.conf import settings from django.contrib.sites.models import Site from django.contrib.sites.requests import RequestSite @@ -19,6 +19,7 @@ from django.db import models from django.db.models import Q from django.utils.translation import gettext_lazy as _ +from edx_django_utils.cache.utils import TieredCache from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from openedx.core.djangoapps.site_configuration.models import SiteConfiguration @@ -49,6 +50,8 @@ class StackedConfigurationModel(ConfigurationModel): """ A ConfigurationModel that stacks Global, Site, Org, Course, and Course Run level configuration values. + + use tieredcache: https://github.com/openedx/django-config-models/blob/32c885d92131fcac1680c518c6f8a127a67f5e2e/config_models/models.py """ class Meta: abstract = True @@ -157,10 +160,9 @@ def current(cls, site=None, org=None, org_course=None, course_key=None): # pyli no arguments are supplied). """ cache_key_name = cls.cache_key_name(site, org, org_course, course_key) - cached = cache.get(cache_key_name) - - if cached is not None: - return cached + cached_response = TieredCache.get_cached_response(cache_key_name) + if cached_response.is_found and cached_response.value is not None: + return cached_response.value # Raise an error if more than one of site/org/course are specified simultaneously. if len([arg for arg in [site, org, org_course, course_key] if arg is not None]) > 1: @@ -235,7 +237,8 @@ def sort_key(override): current = cls(**values) current.provenances = {field.name: provenances[field.name] for field in stackable_fields} # pylint: disable=attribute-defined-outside-init - cache.set(cache_key_name, current, cls.cache_timeout) + + TieredCache.set_all_tiers(cache_key_name, current, cls.cache_timeout) return current @classmethod