add support for redis in settings.py
This commit is contained in:
parent
42d78f1566
commit
d055103e2d
1 changed files with 15 additions and 1 deletions
|
@ -94,13 +94,27 @@ SESSION_ENGINE = "django.contrib.sessions.backends.db"
|
||||||
|
|
||||||
HAS_MEMCACHED = config.has_option('memcached', 'location')
|
HAS_MEMCACHED = config.has_option('memcached', 'location')
|
||||||
if HAS_MEMCACHED:
|
if HAS_MEMCACHED:
|
||||||
REAL_CACHE_USED = True
|
|
||||||
CACHES['default'] = {
|
CACHES['default'] = {
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
|
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
|
||||||
'LOCATION': config.get('memcached', 'location'),
|
'LOCATION': config.get('memcached', 'location'),
|
||||||
}
|
}
|
||||||
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
|
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')
|
HAS_CELERY = config.has_option('celery', 'broker')
|
||||||
if HAS_CELERY:
|
if HAS_CELERY:
|
||||||
BROKER_URL = config.get('celery', 'broker')
|
BROKER_URL = config.get('celery', 'broker')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue