From 332d685e8b41706eac52499f5b76f6d21e3c2aaa Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Mon, 10 Mar 2025 13:48:47 +0800 Subject: [PATCH] add cache --- api/settings.py | 8 ++++++++ entrypoint.sh | 1 + 2 files changed, 9 insertions(+) diff --git a/api/settings.py b/api/settings.py index 310ca45..0404cf1 100644 --- a/api/settings.py +++ b/api/settings.py @@ -106,10 +106,18 @@ PROD_DATABASES = { }, } +PROD_CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.db.DatabaseCache", + "LOCATION": "webpreview_api_cache", + } +} + if DEBUG: DATABASES = DEV_DATABASES else: DATABASES = PROD_DATABASES + CACHES = PROD_CACHES # Password validation # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators diff --git a/entrypoint.sh b/entrypoint.sh index a87fb1d..0232825 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,5 @@ #!/bin/sh +python manage.py createcachetable python manage.py migrate --noinput exec gunicorn --bind 0.0.0.0:8000 api.asgi:application -k uvicorn.workers.UvicornWorker -w 5 \ No newline at end of file