Add django-redis cache

This commit is contained in:
Nyymix 2025-04-14 10:22:52 +03:00
parent 237343b59b
commit 2390968029
2 changed files with 25 additions and 21 deletions

View file

@ -1,24 +1,8 @@
"""
Django settings for config project.
Generated by 'django-admin startproject' using Django 5.1.4.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-$m!a$rjih3i64n8&t3km0u--k0_ij5-a6t!(n_nbz1$)$%0lqn'
@ -27,9 +11,9 @@ DEBUG = True
ALLOWED_HOSTS = []
INTERNAL_IPS = ['localhost', '127.0.0.1',]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
@ -114,7 +98,9 @@ TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
#USE_TZ = True
USE_TZ = False
# Static files (CSS, JavaScript, Images)
@ -141,8 +127,25 @@ MEDIA_ROOT = BASE_DIR / 'media'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Session lifetime 1 year
SESSION_COOKIE_AGE = 31556000
# Sessions
SESSION_COOKIE_AGE = 60 * 60 * 24 * 365 * 5 # 5 vuotta
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_SAMESITE = 'Lax'
# Sessio backend: cache + fallback tietokantaan
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
# Redis cache
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}
# Gotify

View file

@ -1,6 +1,7 @@
Django==5.1.7
django_cleanup==9.0.0
django_imagekit==5.0.0
django-redis==5.4.0
Pillow==11.1.0
pytz==2025.2
Requests==2.32.3