From 87ef19782338eddc00b445eef3b7c66e33ce0a4d Mon Sep 17 00:00:00 2001 From: Disco DeDisco Date: Sat, 21 Feb 2026 23:13:23 -0500 Subject: [PATCH] =?UTF-8?q?enabled=20redis=20alongside=20celery,=20but=20w?= =?UTF-8?q?aiting=20on=20true=20caching=20functionality=E2=80=94flash=20me?= =?UTF-8?q?ssages=20will=20behave=20better=20w.=20cache=5Fpage=20after=20t?= =?UTF-8?q?hey=20rely=20on=20htmx=20library,=20not=20current=20full-page?= =?UTF-8?q?=20reload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .woodpecker.yaml | 2 ++ infra/deploy-playbook.yaml | 3 +++ infra/gamearray.env.j2 | 2 ++ src/apps/dashboard/views.py | 2 ++ src/core/settings.py | 11 ++++++++++- 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.woodpecker.yaml b/.woodpecker.yaml index dc18565..fae41dc 100644 --- a/.woodpecker.yaml +++ b/.woodpecker.yaml @@ -15,6 +15,7 @@ steps: environment: DATABASE_URL: postgresql://postgres:postgres@postgres/python_tdd_test CELERY_BROKER_URL: redis://redis:6379/0 + REDIS_URL: redis://redis:6379/1 commands: - pip install -r requirements.txt - cd ./src @@ -27,6 +28,7 @@ steps: environment: HEADLESS: 1 CELERY_BROKER_URL: redis://redis:6379/0 + REDIS_URL: redis://redis:6379/1 commands: - pip install -r requirements.txt - cd ./src diff --git a/infra/deploy-playbook.yaml b/infra/deploy-playbook.yaml index 6a3d8c1..2b20273 100644 --- a/infra/deploy-playbook.yaml +++ b/infra/deploy-playbook.yaml @@ -136,6 +136,8 @@ DATABASE_URL: "postgresql://gamearray:{{ postgres_password }}@gamearray_postgres/gamearray" MAILGUN_API_KEY: "{{ mailgun_api_key }}" CELERY_BROKER_URL: "redis://gamearray_redis:6379/0" + REDIS_URL: "redis://gamearray_redis:6379/1" + networks: - name: gamearray_net ports: @@ -154,6 +156,7 @@ DATABASE_URL: "postgresql://gamearray:{{ postgres_password }}@gamearray_postgres/gamearray" MAILGUN_API_KEY: "{{ mailgun_api_key }}" CELERY_BROKER_URL: "redis://gamearray_redis:6379/0" + REDIS_URL: "redis://gamearray_redis:6379/1" networks: - name: gamearray_net command: "python -m celery -A core worker -l info" diff --git a/infra/gamearray.env.j2 b/infra/gamearray.env.j2 index 8d1391b..5b43c4b 100644 --- a/infra/gamearray.env.j2 +++ b/infra/gamearray.env.j2 @@ -4,3 +4,5 @@ DJANGO_ALLOWED_HOST={{ django_allowed_host }} DATABASE_URL=postgresql://gamearray:{{ postgres_password }}@gamearray_postgres/gamearray MAILGUN_API_KEY={{ mailgun_api_key }} CELERY_BROKER_URL=redis://gamearray_redis:6379/0 +REDIS_URL=redis://gamearray_redis:6379/1 + diff --git a/src/apps/dashboard/views.py b/src/apps/dashboard/views.py index fc8359c..27a8e1c 100644 --- a/src/apps/dashboard/views.py +++ b/src/apps/dashboard/views.py @@ -1,9 +1,11 @@ from django.http import HttpResponseForbidden from django.shortcuts import redirect, render + from .forms import ExistingListItemForm, ItemForm from .models import Item, List from apps.lyric.models import User + def home_page(request): return render(request, "apps/dashboard/home.html", {"form": ItemForm()}) diff --git a/src/core/settings.py b/src/core/settings.py index 9916bba..a05ac4f 100644 --- a/src/core/settings.py +++ b/src/core/settings.py @@ -109,8 +109,17 @@ else: } } -# Celery +# Celery & Redis CELERY_BROKER_URL = os.environ.get('CELERY_BROKER_URL', 'redis://localhost:6379/0') +REDIS_URL = os.environ.get('REDIS_URL') +if REDIS_URL: + CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.redis.RedisCache', + 'LOCATION': REDIS_URL, + } + } + SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' # Password validation # https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators