diff --git a/api/ovdashboard_api/dav_calendar.py b/api/ovdashboard_api/dav_calendar.py index a4f8566..cea94f0 100644 --- a/api/ovdashboard_api/dav_calendar.py +++ b/api/ovdashboard_api/dav_calendar.py @@ -11,6 +11,7 @@ from vobject.icalendar import VEvent from .async_helpers import get_ttl_hash, run_in_executor, timed_alru_cache from .dav_common import caldav_principal +from .settings import SETTINGS _logger = logging.getLogger(__name__) @@ -123,13 +124,13 @@ class DavCalendar: @property async def calendar(self) -> Calendar: return await _get_calendar( - ttl_hash=get_ttl_hash(20), + ttl_hash=get_ttl_hash(SETTINGS.cache_seconds), calendar_name=self.calendar_name, ) @property async def events(self) -> list[CalEvent]: return await _get_calendar_events( - ttl_hash=get_ttl_hash(20), + ttl_hash=get_ttl_hash(SETTINGS.cache_seconds), calendar_name=self.calendar_name, ) diff --git a/api/ovdashboard_api/dav_file.py b/api/ovdashboard_api/dav_file.py index 137e7a0..acaa22c 100644 --- a/api/ovdashboard_api/dav_file.py +++ b/api/ovdashboard_api/dav_file.py @@ -7,6 +7,7 @@ from webdav3.client import Resource from .async_helpers import get_ttl_hash, run_in_executor, timed_alru_cache from .dav_common import webdav_resource +from .settings import SETTINGS _logger = logging.getLogger(__name__) @@ -34,7 +35,7 @@ class DavFile: @property async def __buffer(self) -> BytesIO: return await _get_buffer( - ttl_hash=get_ttl_hash(20), + ttl_hash=get_ttl_hash(SETTINGS.cache_seconds), remote_path=self.remote_path, ) diff --git a/api/ovdashboard_api/settings.py b/api/ovdashboard_api/settings.py index 554e42c..b55f4f2 100644 --- a/api/ovdashboard_api/settings.py +++ b/api/ovdashboard_api/settings.py @@ -32,6 +32,7 @@ class Settings(BaseSettings): dav_path: str = "ovdashboard" ticker_separator: str = " +++ " + cache_seconds: int = 30 @property def caldav_url(self) -> str: