add support for redis in settings.py

This commit is contained in:
Laura Klünder 2017-06-21 17:08:19 +02:00
parent 42d78f1566
commit d055103e2d

View file

@ -94,13 +94,27 @@ SESSION_ENGINE = "django.contrib.sessions.backends.db"
HAS_MEMCACHED = config.has_option('memcached', 'location')
if HAS_MEMCACHED:
REAL_CACHE_USED = True
CACHES['default'] = {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': config.get('memcached', 'location'),
}
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
HAS_REDIS = config.has_option('redis', 'location')
if HAS_REDIS:
CACHES['redis'] = {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": config.get('redis', 'location'),
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
if not HAS_MEMCACHED:
CACHES['default'] = CACHES['redis']
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
else:
SESSION_CACHE_ALIAS = "redis"
HAS_CELERY = config.has_option('celery', 'broker')
if HAS_CELERY:
BROKER_URL = config.get('celery', 'broker')