From 4477acfe503fa4b308a4fb94ab7098a4e0e87187 Mon Sep 17 00:00:00 2001 From: Richard Moch Date: Mon, 17 Dec 2018 17:37:03 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(cache)=20configure=20Django=20cach?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default configuration was using LocMemCache backend preventing cache to be shared between containers. By example, lms course plan was not invalidated when modifications were made in studio. We now use Memcached as default cache and LocMemcach for 'location mapping' as recommended by edX https://github.com/edx/edx-platform/blob/master/lms/envs/aws.py#L199 --- config/cms/docker_run_production.py | 8 ++++++-- config/lms/docker_run_production.py | 16 ++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/cms/docker_run_production.py b/config/cms/docker_run_production.py index 24f9676c..817a1703 100644 --- a/config/cms/docker_run_production.py +++ b/config/cms/docker_run_production.py @@ -146,9 +146,13 @@ CACHES = config( "CACHES", default={ - "default": { + "loc_cache": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", - "LOCATION": "unique-snowflake", + "LOCATION": "edx_location_mem_cache", + }, + "default": { + "BACKEND": "django.core.cache.backends.memcached.MemcachedCache", + "LOCATION": "memcached:11211", } }, formatter=json.loads, diff --git a/config/lms/docker_run_production.py b/config/lms/docker_run_production.py index e5c88e87..5473db16 100644 --- a/config/lms/docker_run_production.py +++ b/config/lms/docker_run_production.py @@ -225,22 +225,18 @@ CACHES = config( "CACHES", default={ - "default": { + "loc_cache": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", - "LOCATION": "unique-snowflake", + "LOCATION": "edx_location_mem_cache", + }, + "default": { + "BACKEND": "django.core.cache.backends.memcached.MemcachedCache", + "LOCATION": "memcached:11211", } }, formatter=json.loads, ) -# Cache used for location mapping -- called many times with the same key/value -# in a given request. -if "loc_cache" not in CACHES: - CACHES["loc_cache"] = { - "BACKEND": "django.core.cache.backends.locmem.LocMemCache", - "LOCATION": "edx_location_mem_cache", - } - # Email overrides DEFAULT_FROM_EMAIL = config("DEFAULT_FROM_EMAIL", default=DEFAULT_FROM_EMAIL) DEFAULT_FEEDBACK_EMAIL = config(