1
0
forked from erp-dev/erp

feat: added cache to plate order list api

This commit is contained in:
2025-12-23 16:25:51 +08:00
parent 7ced07d402
commit b9a0859030
2 changed files with 29 additions and 0 deletions

View File

@@ -201,6 +201,32 @@ DATABASES = {
}
# Cache configuration
# https://docs.djangoproject.com/en/5.2/topics/cache/
# Django 5.x 内置 Redis 缓存后端,使用 redis 包(已安装)
# 容器内默认使用 redis://redis:6379/0本地开发可使用 redis://localhost:6379/0
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
'LOCATION': env(
'CACHE_URL',
default='redis://redis:6379/0', # 容器内默认地址
),
'OPTIONS': {
# Redis 连接选项
'socket_connect_timeout': 5, # 连接超时(秒)
'socket_timeout': 5, # 操作超时(秒)
'retry_on_timeout': True, # 超时后重试
'health_check_interval': 30, # 健康检查间隔(秒)
},
# 键前缀,避免不同项目/环境之间的键冲突
'KEY_PREFIX': env('CACHE_KEY_PREFIX', default='flower'),
# 默认过期时间None 表示永不过期(由具体使用场景决定)
'TIMEOUT': env.int('CACHE_DEFAULT_TIMEOUT', default=300), # 默认 5 分钟
}
}
# Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators