Browse Source

add support for CACHE_URL

Tobias McNulty 7 years ago
parent
commit
1f94861634
2 changed files with 8 additions and 1 deletions
  1. 6 1
      bakerydemo/settings/production.py
  2. 2 0
      requirements/production.txt

+ 6 - 1
bakerydemo/settings/production.py

@@ -1,8 +1,10 @@
 import os
-import dj_database_url
 import random
 import string
 
+import dj_database_url
+import django_cache_url
+
 from .base import *
 
 DEBUG = os.getenv('DJANGO_DEBUG', 'off') == 'on'
@@ -39,6 +41,9 @@ AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID', '')
 AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY', '')
 AWS_REGION = os.getenv('AWS_REGION', '')
 
+# configure CACHES from CACHE_URL environment variable (defaults to locmem if no CACHE_URL is set)
+CACHES = {'default': django_cache_url.config()}
+
 # Configure Elasticsearch, if present in os.environ
 ELASTICSEARCH_ENDPOINT = os.getenv('ELASTICSEARCH_ENDPOINT', '')
 

+ 2 - 0
requirements/production.txt

@@ -9,3 +9,5 @@ django-storages==1.5.2
 # For retrieving credentials and signing requests to Elasticsearch
 botocore==1.7.10
 aws-requests-auth==0.4.0
+django-redis==4.8.0
+django_cache_url==2.0.0