SETTINGS.cache_size

This commit is contained in:
Jörn-Michael Miehe 2022-09-06 07:54:44 +00:00
parent d09fe0f0e2
commit f99e45c7bb
4 changed files with 5 additions and 4 deletions

View file

@ -94,7 +94,7 @@ class CalEvent(BaseModel):
return cls.parse_obj(data) return cls.parse_obj(data)
@timed_alru_cache(maxsize=20) @timed_alru_cache(maxsize=SETTINGS.cache_size)
async def _get_calendar( async def _get_calendar(
calendar_name: str, calendar_name: str,
) -> Calendar: ) -> Calendar:
@ -109,7 +109,7 @@ async def _get_calendar(
return await _inner() return await _inner()
@timed_alru_cache(maxsize=20) @timed_alru_cache(maxsize=SETTINGS.cache_size)
async def _get_calendar_events( async def _get_calendar_events(
calendar_name: str, calendar_name: str,
) -> list[CalEvent]: ) -> list[CalEvent]:

View file

@ -20,7 +20,7 @@ _WEBDAV_CLIENT = WebDAVclient({
}) })
@lru_cache @lru_cache(maxsize=SETTINGS.cache_size)
def webdav_resource(remote_path: Any) -> WebDAVResource: def webdav_resource(remote_path: Any) -> WebDAVResource:
""" """
Gets a resource using the main WebDAV client. Gets a resource using the main WebDAV client.

View file

@ -18,7 +18,7 @@ from .settings import SETTINGS
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@timed_alru_cache(maxsize=20) @timed_alru_cache(maxsize=SETTINGS.cache_size)
async def _get_buffer( async def _get_buffer(
remote_path: Any, remote_path: Any,
) -> BytesIO: ) -> BytesIO:

View file

@ -58,6 +58,7 @@ class Settings(BaseSettings):
caldav: DavSettings = DavSettings() caldav: DavSettings = DavSettings()
cache_seconds: int = 30 cache_seconds: int = 30
cache_size: int = 30
class Config: class Config:
env_nested_delimiter = "__" env_nested_delimiter = "__"