Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Use redis for cache and session storage

Roland Geider4e8a22e25d5a
diff --git a/extras/docker/compose/dev.env b/extras/docker/compose/dev.env
index be833a91f..c0532b43a 100644
--- a/extras/docker/compose/dev.env
+++ b/extras/docker/compose/dev.env
@@ -8,9 +8,9 @@ DJANGO_DB_HOST=db
DJANGO_DB_PORT=5432
# Cache
-DJANGO_CACHE_BACKEND=django.core.cache.backends.memcached.MemcachedCache
-DJANGO_CACHE_HOST=cache
-DJANGO_CACHE_PORT=11211
+DJANGO_CACHE_BACKEND=django_redis.cache.RedisCache
+DJANGO_CACHE_LOCATION=redis://cache:6379/1
DJANGO_CACHE_TIMEOUT=100
+DJANGO_CACHE_CLIENT_CLASS=django_redis.client.DefaultClient
DJANGO_MEDIA_ROOT=/home/wger/media
diff --git a/extras/docker/compose/docker-compose.yml b/extras/docker/compose/docker-compose.yml
index f7251a2c2..e90db7026 100644
--- a/extras/docker/compose/docker-compose.yml
+++ b/extras/docker/compose/docker-compose.yml
@@ -14,17 +14,23 @@ services:
depends_on:
- db
- cache
+
db:
image: postgres:12.0-alpine
volumes:
- wger-postgres-data:/var/lib/postgresql/data/
+ expose:
+ - 5432
environment:
- POSTGRES_USER=wger
- POSTGRES_PASSWORD=wger
- POSTGRES_DB=wger
cache:
- image: memcached
+ restart: always
+ image: redis:latest
+ expose:
+ - 6379
volumes:
wger-postgres-data:
diff --git a/extras/docker/development/Dockerfile b/extras/docker/development/Dockerfile
index 05e1cee90..0e8c0445d 100644
--- a/extras/docker/development/Dockerfile
+++ b/extras/docker/development/Dockerfile
@@ -49,7 +49,7 @@ COPY ${DOCKER_DIR}/entrypoint.sh /home/wger/entrypoint.sh
RUN chmod +x /home/wger/entrypoint.sh
RUN pip3 install --no-cache /wheels/* \
&& pip3 install psycopg2-binary \
- && pip3 install python-memcached \
+ && pip3 install django-redis \
&& python3 setup.py develop \
&& npm install -g bower
diff --git a/extras/docker/development/settings.py b/extras/docker/development/settings.py
index 2ed3e7506..72dbe6f1b 100644
--- a/extras/docker/development/settings.py
+++ b/extras/docker/development/settings.py
@@ -57,8 +57,7 @@ MEDIA_URL = '/media/'
# Allow all hosts to access the application. Change if used in production.
ALLOWED_HOSTS = '*'
-# This might be a good idea if you setup memcached
-#SESSION_ENGINE = "django.contrib.sessions.backends.cache"
+SESSION_ENGINE = "django.contrib.sessions.backends.cache"
# Configure a real backend in production
if DEBUG:
@@ -71,8 +70,11 @@ if os.environ.get("DJANGO_CACHE_BACKEND"):
CACHES = {
'default': {
'BACKEND': os.environ.get("DJANGO_CACHE_BACKEND"),
- 'LOCATION': os.environ.get("DJANGO_CACHE_HOST") + ":" + os.environ.get("DJANGO_CACHE_PORT"),
- 'TIMEOUT': os.environ.get("DJANGO_CACHE_TIMEOUT")
+ 'LOCATION': os.environ.get("DJANGO_CACHE_LOCATION"),
+ 'TIMEOUT': os.environ.get("DJANGO_CACHE_TIMEOUT"),
+ 'OPTIONS': {
+ 'CLIENT_CLASS': os.environ.get("DJANGO_CACHE_CLIENT_CLASS"),
+ }
}
}