Cleanup and remove deprecated RequestCache Django app

ARCH-223
This commit is contained in:
Nimisha Asthagiri
2018-08-30 14:32:29 -04:00
committed by Robert Raposa
parent 53d8a04b88
commit 700a902b68
54 changed files with 595 additions and 600 deletions

View File

@@ -50,6 +50,7 @@ from six import text_type
from slumber.exceptions import HttpClientError, HttpServerError
from user_util import user_util
from edx_django_utils.cache import RequestCache
import lms.lib.comment_client as cc
from student.signals import UNENROLL_DONE, ENROLL_STATUS_CHANGE, ENROLLMENT_TRACK_UPDATED
from lms.djangoapps.certificates.models import GeneratedCertificate
@@ -62,7 +63,6 @@ from courseware.models import (
from enrollment.api import _default_course_mode
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.request_cache import clear_cache, get_cache
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.xmodule_django.models import NoneToEmptyManager
from openedx.core.djangolib.model_mixins import DeletableByUserValue
@@ -2069,7 +2069,7 @@ class CourseEnrollment(models.Model):
"""
# before populating the cache with another bulk set of data,
# remove previously cached entries to keep memory usage low.
clear_cache(cls.MODE_CACHE_NAMESPACE)
RequestCache(cls.MODE_CACHE_NAMESPACE).clear()
records = cls.objects.filter(user__in=users, course_id=course_key).select_related('user')
cache = cls._get_mode_active_request_cache()
@@ -2080,9 +2080,9 @@ class CourseEnrollment(models.Model):
@classmethod
def _get_mode_active_request_cache(cls):
"""
Returns the request-specific cache for CourseEnrollment
Returns the request-specific cache for CourseEnrollment as dict.
"""
return get_cache(cls.MODE_CACHE_NAMESPACE)
return RequestCache(cls.MODE_CACHE_NAMESPACE).data
@classmethod
def _get_enrollment_in_request_cache(cls, user, course_key):

View File

@@ -10,7 +10,7 @@ from collections import defaultdict
from django.contrib.auth.models import User
from opaque_keys.edx.django.models import CourseKeyField
from openedx.core.djangoapps.request_cache import get_cache
from openedx.core.lib.cache_utils import get_cache
from student.models import CourseAccessRole
log = logging.getLogger(__name__)

View File

@@ -24,6 +24,7 @@ from student.models import (
UserProfile,
get_retired_email_by_email
)
from openedx.core.lib.request_utils import safe_get_host
from student.tests.factories import PendingEmailChangeFactory, RegistrationFactory, UserFactory
from student.views import (
SETTING_CHANGE_INITIATED,
@@ -33,7 +34,6 @@ from student.views import (
)
from student.views import generate_activation_email_context, send_reactivation_email_for_user
from third_party_auth.views import inactive_user_view
from util.request import safe_get_host
from util.testing import EventTestMixin