Use redis for cache.
- Cache use db #1 of redis. - Channel layer (of channels) use db #0 of redis. - `settings` try getting redis connection variables from environment. - Drop memcached system
This commit is contained in:
parent
ab31c20649
commit
36771c2c4f
3 changed files with 30 additions and 13 deletions
|
@ -115,15 +115,6 @@ USE_L10N = True
|
|||
USE_TZ = True
|
||||
|
||||
|
||||
# Cache system
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
'LOCATION': '127.0.0.1:11211',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
||||
|
||||
|
@ -176,13 +167,39 @@ RECAPTCHA_PUBLIC_KEY = "DUMMY"
|
|||
RECAPTCHA_PRIVATE_KEY = "DUMMY"
|
||||
RECAPTCHA_USE_SSL = True
|
||||
|
||||
# Channels settings
|
||||
|
||||
# Redis settings (for cache and channel layers)
|
||||
|
||||
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
||||
REDIS_USER = os.environ.get("REDIS_USER", "")
|
||||
REDIS_PASS = os.environ.get("REDIS_PASS", "")
|
||||
REDIS_PORT = os.environ.get("REDIS_PORT", "6379")
|
||||
|
||||
REDIS_AUTH = REDIS_USER+":"+REDIS_PASS+"@" if REDIS_USER or REDIS_PASS else ''
|
||||
REDIS_BASE_URL = "redis://" + REDIS_AUTH + REDIS_HOST + ":" + REDIS_PORT
|
||||
|
||||
|
||||
# Cache settings (use db #1 of redis)
|
||||
|
||||
CACHE_REDIS_URL = REDIS_BASE_URL + "/1"
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'redis_cache.RedisCache',
|
||||
'LOCATION': CACHE_REDIS_URL,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Channels settings (use db #0 of redis)
|
||||
|
||||
CHANNEL_REDIS_URL = REDIS_BASE_URL + "/0"
|
||||
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "asgi_redis.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts": [(os.environ.get("REDIS_HOST", "localhost"), 6379)],
|
||||
"hosts": [CHANNEL_REDIS_URL],
|
||||
},
|
||||
"ROUTING": "cof.routing.channel_routing",
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ DBPASSWD="4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4"
|
|||
|
||||
# Installation de paquets utiles
|
||||
apt-get update && apt-get install -y python3-pip python3-dev python3-venv \
|
||||
libmysqlclient-dev libjpeg-dev git redis-server memcached
|
||||
libmysqlclient-dev libjpeg-dev git redis-server
|
||||
pip install -U pip
|
||||
|
||||
# Configuration et installation de mysql. Le mot de passe root est le même que
|
||||
|
|
|
@ -5,6 +5,7 @@ django-autoslug==1.9.3
|
|||
django-cas-ng==3.5.5
|
||||
django-grappelli==2.8.1
|
||||
django-recaptcha==1.0.5
|
||||
django-redis-cache==1.7.1
|
||||
mysqlclient==1.3.7
|
||||
Pillow==3.3.0
|
||||
six==1.10.0
|
||||
|
@ -21,4 +22,3 @@ git+https://git.eleves.ens.fr/cof-geek/django_custommail.git#egg=django_customma
|
|||
ldap3
|
||||
git+https://github.com/Aureplop/channels.git#egg=channels
|
||||
python-dateutil
|
||||
python-memcached
|
||||
|
|
Loading…
Reference in a new issue