Reimplement caching

This commit is contained in:
Keannu Christian Bernasol 2025-09-03 02:25:42 +08:00
parent bae2cc653e
commit d99c82bef4
7 changed files with 89 additions and 5 deletions

View file

@ -43,8 +43,10 @@ class Config(BaseModel):
default=False,
description="Whether to serve media files locally as oppossed to using a cloud storage solution.",
)
SMTP_HOST: StrictStr = Field(required=True, description="SMTP server address")
SMTP_PORT: int = Field(default=587, description="SMTP server port (default: 587)")
SMTP_HOST: StrictStr = Field(
required=True, description="SMTP server address")
SMTP_PORT: int = Field(
default=587, description="SMTP server port (default: 587)")
SMTP_USE_TLS: bool = Field(
default=True, description="Whether to use TLS for SMTP connections"
)
@ -66,6 +68,18 @@ class Config(BaseModel):
DEBUG_USER_PASSWORD: StrictStr = Field(
required=True, description="Password for test users created during development"
)
CACHE_USERNAME: StrictStr = Field(
required=True, description="Cache server authentication username"
)
CACHE_PASSWORD: StrictStr = Field(
required=True, description="Cache server authentication password"
)
CACHE_HOST: StrictStr = Field(
required=True, description="Server host used for caching"
)
CACHE_PORT: int = Field(
required=True, description="Server port used for caching"
)
@field_validator("CORS_ORIGINS", "ALLOWED_HOSTS", mode="before")
def parse_list(cls, v):

View file

@ -242,8 +242,21 @@ SPECTACULAR_SETTINGS = {
"SERVE_INCLUDE_SCHEMA": False,
}
# Pygraphviz
GRAPH_MODELS = {
"all_applications": True,
"group_models": True,
}
# Caching
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": f"redis://{config.CACHE_USERNAME}:{config.CACHE_PASSWORD}@{config.CACHE_HOST}:{config.CACHE_PORT}/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
},
}
}