add cache

This commit is contained in:
2025-03-10 13:48:47 +08:00
parent 0eeab2e7b9
commit 332d685e8b
2 changed files with 9 additions and 0 deletions

View File

@@ -106,10 +106,18 @@ PROD_DATABASES = {
}, },
} }
PROD_CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.db.DatabaseCache",
"LOCATION": "webpreview_api_cache",
}
}
if DEBUG: if DEBUG:
DATABASES = DEV_DATABASES DATABASES = DEV_DATABASES
else: else:
DATABASES = PROD_DATABASES DATABASES = PROD_DATABASES
CACHES = PROD_CACHES
# Password validation # Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators

View File

@@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
python manage.py createcachetable
python manage.py migrate --noinput python manage.py migrate --noinput
exec gunicorn --bind 0.0.0.0:8000 api.asgi:application -k uvicorn.workers.UvicornWorker -w 5 exec gunicorn --bind 0.0.0.0:8000 api.asgi:application -k uvicorn.workers.UvicornWorker -w 5