/
/
/
1"""Constants for the cache controller."""
2
3from __future__ import annotations
4
5import logging
6from contextvars import ContextVar
7
8from music_assistant.constants import MASS_LOGGER_NAME
9
10LOGGER = logging.getLogger(f"{MASS_LOGGER_NAME}.cache")
11CONF_CLEAR_CACHE = "clear_cache"
12DEFAULT_CACHE_EXPIRATION = 86400 * 30 # 30 days
13DB_SCHEMA_VERSION = 9
14MAX_CACHE_DB_SIZE_MB = 2048
15CACHE_DATABASE_CLEANUP_TASK_ID = "cache_database_cleanup"
16# stale-while-revalidate fallback rows are kept past their expiration so they can still be
17# served while a refresh runs; the cleanup task removes those not refreshed within this window
18# (their key is no longer requested) to keep the cache from growing without bound.
19SWR_FALLBACK_MAX_AGE = 86400 * 90 # 90 days
20
21BYPASS_CACHE: ContextVar[bool] = ContextVar("BYPASS_CACHE", default=False)
22