diff --git a/api/ovdashboard_api/dav_calendar.py b/api/ovdashboard_api/dav_calendar.py index cbe46b2..d47c64c 100644 --- a/api/ovdashboard_api/dav_calendar.py +++ b/api/ovdashboard_api/dav_calendar.py @@ -94,7 +94,7 @@ class CalEvent(BaseModel): return cls.parse_obj(data) -@timed_alru_cache(maxsize=20) +@timed_alru_cache(maxsize=SETTINGS.cache_size) async def _get_calendar( calendar_name: str, ) -> Calendar: @@ -109,7 +109,7 @@ async def _get_calendar( return await _inner() -@timed_alru_cache(maxsize=20) +@timed_alru_cache(maxsize=SETTINGS.cache_size) async def _get_calendar_events( calendar_name: str, ) -> list[CalEvent]: diff --git a/api/ovdashboard_api/dav_common.py b/api/ovdashboard_api/dav_common.py index bcac62c..473ee19 100644 --- a/api/ovdashboard_api/dav_common.py +++ b/api/ovdashboard_api/dav_common.py @@ -20,7 +20,7 @@ _WEBDAV_CLIENT = WebDAVclient({ }) -@lru_cache +@lru_cache(maxsize=SETTINGS.cache_size) def webdav_resource(remote_path: Any) -> WebDAVResource: """ Gets a resource using the main WebDAV client. diff --git a/api/ovdashboard_api/dav_file.py b/api/ovdashboard_api/dav_file.py index 7fc1e11..c6a532b 100644 --- a/api/ovdashboard_api/dav_file.py +++ b/api/ovdashboard_api/dav_file.py @@ -18,7 +18,7 @@ from .settings import SETTINGS _logger = logging.getLogger(__name__) -@timed_alru_cache(maxsize=20) +@timed_alru_cache(maxsize=SETTINGS.cache_size) async def _get_buffer( remote_path: Any, ) -> BytesIO: diff --git a/api/ovdashboard_api/settings.py b/api/ovdashboard_api/settings.py index 3b07198..652b02d 100644 --- a/api/ovdashboard_api/settings.py +++ b/api/ovdashboard_api/settings.py @@ -58,6 +58,7 @@ class Settings(BaseSettings): caldav: DavSettings = DavSettings() cache_seconds: int = 30 + cache_size: int = 30 class Config: env_nested_delimiter = "__"