Browse Source

Use of Redis.

development-ci
Franco Masotti 11 months ago
parent
commit
f0954e0266
Signed by: frnmst
GPG Key ID: 24116ED85666780A
  1. 1
      Pipfile
  2. 8
      SECRET_SETTINGS.py.dist
  3. 19
      django_futils/settings.py
  4. 15
      docker-compose.yml.dist
  5. 1
      setup.py

1
Pipfile

@ -61,6 +61,7 @@ django-extensions = "~=3.1"
django-leaflet = "~=0.28"
django-htmlmin = "~=0.11"
geopy = "~=2.2"
django-redis = "~=5.0"
[requires]
python_version = "*"

8
SECRET_SETTINGS.py.dist

@ -88,3 +88,11 @@ DB_USER = 'postgres'
DB_PASSWORD = 'postgres'
DB_HOST = 'db'
DB_PORT = '5432'
#########
# Redis #
#########
REDIS_HOST = 'redis'
REDIS_PORT = '6379'
REDIS_DB = '1'

19
django_futils/settings.py

@ -41,8 +41,9 @@ import django_futils.constants as const
from SECRET_SETTINGS import (ALLOWED_HOSTS, DB_HOST, DB_NAME, DB_PASSWORD,
DB_PORT, DB_USER, DEBUG, INTERNAL_IPS,
LANGUAGE_CODE, LOCALE_DIR_SUFFIX, MEDIA_ROOT,
MEDIA_URL, SECRET_KEY, STATIC_ROOT_SUFFIX,
STATIC_URL, STATICFILES_DIR_SUFFIX, TIME_ZONE,
MEDIA_URL, REDIS_DB, REDIS_HOST, REDIS_PORT,
SECRET_KEY, STATIC_ROOT_SUFFIX, STATIC_URL,
STATICFILES_DIR_SUFFIX, TIME_ZONE,
USE_X_FORWARDED_HOST)
# Optional variables.
@ -109,6 +110,9 @@ INSTALLED_APPS = [
]
MIDDLEWARE = [
# See
# https://michal.karzynski.pl/blog/2013/07/14/using-redis-as-django-session-store-and-cache-backend/
'django.middleware.cache.UpdateCacheMiddleware',
'htmlmin.middleware.HtmlMinifyMiddleware',
'htmlmin.middleware.MarkRequestMiddleware',
'django.middleware.security.SecurityMiddleware',
@ -120,6 +124,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
]
AUTHENTICATION_BACKENDS = [
@ -145,6 +150,16 @@ TEMPLATES = [
},
]
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://" + REDIS_HOST + ':' + REDIS_PORT + '/' + REDIS_DB,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}
# Disable caching for debug so we can test the templates without reloading
# the server.
if DEBUG:

15
docker-compose.yml.dist

@ -21,11 +21,20 @@
version: '3.8'
volumes:
redis:
services:
dependencies:
image: docker_debian_postgis_django
build:
context: https://software.franco.net.eu.org/frnmst/docker-debian-postgis-django.git#6.0.0
redis:
image: redis:6.2.5
restart: always
hostname: redis
db:
# See
# https://github.com/frnmst/docker-debian-postgis-django/blob/master/README.md#database
@ -50,12 +59,14 @@ services:
context: .
dockerfile: Dockerfile
restart: on-failure
links:
- db
depends_on:
- dependencies
- db
web:
image: django_futils_web
restart: on-failure
depends_on:
links:
- db
- redis

1
setup.py

@ -61,5 +61,6 @@ setup(
'django-leaflet>=0.28,<0.29',
'django-htmlmin>=0.11,<0.12',
'geopy>=2.2,<2.3',
'django-redis>=5.0,<5.1',
],
)

Loading…
Cancel
Save