Skip to content

Commit

Permalink
🔧(cache) configure Django cache
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rmoch committed Dec 18, 2018
1 parent dcc9dac commit 4477acf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 6 additions & 2 deletions config/cms/docker_run_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 6 additions & 10 deletions config/lms/docker_run_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4477acf

Please sign in to comment.