forked from erp-dev/erp
feat: added cache to plate order list api
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user