Retire deprecated RequestCache.

ARCH-223
This commit is contained in:
Robert Raposa
2018-08-28 16:46:59 -04:00
committed by Nimisha Asthagiri
parent fe5279ed5c
commit 3df339a56a
35 changed files with 106 additions and 173 deletions

View File

@@ -13,11 +13,12 @@ from django.db.models import Q
from django.dispatch import receiver
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from edx_django_utils.cache import RequestCache
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.django.models import CourseKeyField
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.request_cache.middleware import RequestCache, ns_request_cached
from openedx.core.djangoapps.request_cache.middleware import ns_request_cached
Mode = namedtuple('Mode',
[
@@ -727,7 +728,7 @@ class CourseMode(models.Model):
@receiver(models.signals.post_delete, sender=CourseMode)
def invalidate_course_mode_cache(sender, **kwargs): # pylint: disable=unused-argument
"""Invalidate the cache of course modes. """
RequestCache.clear_request_cache(name=CourseMode.CACHE_NAMESPACE)
RequestCache(namespace=CourseMode.CACHE_NAMESPACE).clear()
def get_cosmetic_verified_display_price(course):

View File

@@ -7,12 +7,12 @@ from django.http import HttpResponse
from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import override_settings
from edx_django_utils.cache import RequestCache
from mock import Mock, patch
from edxmako import LOOKUP, add_lookup
from edxmako.request_context import get_template_request_context
from edxmako.shortcuts import is_any_marketing_link_set, is_marketing_link_set, marketing_link, render_to_string
from openedx.core.djangoapps.request_cache.middleware import RequestCache
from student.tests.factories import UserFactory
from util.testing import UrlResetMixin
@@ -89,7 +89,7 @@ class MakoRequestContextTest(TestCase):
self.request.user = self.user
self.response = Mock(spec=HttpResponse)
self.addCleanup(RequestCache.clear_request_cache)
self.addCleanup(RequestCache.clear_all_namespaces)
def test_with_current_request(self):
"""
@@ -128,7 +128,7 @@ class MakoRequestContextTest(TestCase):
self.assertIsNotNone(get_template_request_context())
mock_get_current_request.assert_not_called()
RequestCache.clear_request_cache()
RequestCache.clear_all_namespaces()
with patch('edxmako.request_context.get_current_request', return_value=None):
# requestcontext should be None, because the cache isn't filled

View File

@@ -23,8 +23,8 @@ from django.core.cache import caches, InvalidCacheBackendError
import django.dispatch
import django.utils
from django.utils.translation import get_language, to_locale
from edx_django_utils.cache import DEFAULT_REQUEST_CACHE
from openedx.core.djangoapps.request_cache.middleware import RequestCache
from xmodule.contentstore.django import contentstore
from xmodule.modulestore.draft_and_published import BranchSettingMixin
from xmodule.modulestore.mixed import MixedModuleStore
@@ -249,7 +249,7 @@ def create_modulestore_instance(
if key in _options and isinstance(_options[key], basestring):
_options[key] = load_function(_options[key])
request_cache = RequestCache.get_request_cache()
request_cache = DEFAULT_REQUEST_CACHE
try:
metadata_inheritance_cache = caches['mongo_metadata_inheritance']
@@ -278,14 +278,9 @@ def create_modulestore_instance(
if disabled_xblocks is None:
return []
if request_cache:
if 'disabled_xblock_types' not in request_cache.data:
request_cache.data['disabled_xblock_types'] = [block.name for block in disabled_xblocks()]
return request_cache.data['disabled_xblock_types']
else:
disabled_xblock_types = [block.name for block in disabled_xblocks()]
return disabled_xblock_types
if 'disabled_xblock_types' not in request_cache.data:
request_cache.data['disabled_xblock_types'] = [block.name for block in disabled_xblocks()]
return request_cache.data['disabled_xblock_types']
return class_(
contentstore=content_store,