diff --git a/api/ovdashboard_api/async_helpers.py b/api/ovdashboard_api/async_helpers.py index a4a7ef9..82677df 100644 --- a/api/ovdashboard_api/async_helpers.py +++ b/api/ovdashboard_api/async_helpers.py @@ -8,6 +8,8 @@ from time import time from async_lru import alru_cache +from .settings import SETTINGS + def run_in_executor(f): """ @@ -27,13 +29,13 @@ def run_in_executor(f): return wrapper -def get_ttl_hash(seconds: int = 20) -> int: +def get_ttl_hash() -> int: """ Return the same value within `seconds` time period. https://stackoverflow.com/a/55900800 """ - return round(time() / seconds) + return round(time() / SETTINGS.cache_seconds) def timed_alru_cache(*decorator_args, **decorator_kwargs): diff --git a/api/ovdashboard_api/dav_calendar.py b/api/ovdashboard_api/dav_calendar.py index 6af3d17..dc7a713 100644 --- a/api/ovdashboard_api/dav_calendar.py +++ b/api/ovdashboard_api/dav_calendar.py @@ -183,7 +183,7 @@ class DavCalendar: """ return await _get_calendar( - ttl_hash=get_ttl_hash(SETTINGS.cache_seconds), + ttl_hash=get_ttl_hash(), calendar_name=self.calendar_name, ) @@ -194,6 +194,6 @@ class DavCalendar: """ return await _get_calendar_events( - ttl_hash=get_ttl_hash(SETTINGS.cache_seconds), + ttl_hash=get_ttl_hash(), calendar_name=self.calendar_name, ) diff --git a/api/ovdashboard_api/dav_file.py b/api/ovdashboard_api/dav_file.py index c6a532b..4ba7022 100644 --- a/api/ovdashboard_api/dav_file.py +++ b/api/ovdashboard_api/dav_file.py @@ -61,7 +61,7 @@ class DavFile: """ return await _get_buffer( - ttl_hash=get_ttl_hash(SETTINGS.cache_seconds), + ttl_hash=get_ttl_hash(), remote_path=self.remote_path, )