get_ttl_hash without param
This commit is contained in:
parent
0de6b1d416
commit
f4b781912b
3 changed files with 7 additions and 5 deletions
|
@ -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):
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue