mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-24 05:23:04 +00:00
hack: invalidate cache on file write
This commit is contained in:
parent
5c583bd478
commit
4415c0f861
1 changed files with 5 additions and 1 deletions
|
@ -2,6 +2,7 @@ import re
|
|||
from io import BytesIO
|
||||
|
||||
from cache import AsyncTTL
|
||||
from cache.key import KEY
|
||||
from webdav3.client import Client as WebDAVclient
|
||||
|
||||
from .settings import SETTINGS
|
||||
|
@ -42,7 +43,7 @@ class WebDAV:
|
|||
return cls._webdav_client.check(path)
|
||||
|
||||
@classmethod
|
||||
@AsyncTTL(time_to_live=SETTINGS.webdav.cache_ttl, skip_args=1)
|
||||
@(_rb_ttl := AsyncTTL(time_to_live=SETTINGS.webdav.cache_ttl, skip_args=1))
|
||||
async def read_bytes(cls, path: str) -> bytes:
|
||||
"""
|
||||
Datei aus Pfad `path` als bytes laden
|
||||
|
@ -70,6 +71,9 @@ class WebDAV:
|
|||
|
||||
cls._webdav_client.resource(path).read_from(buffer)
|
||||
|
||||
# Cache-Eintrag entfernen (hack: siehe AsyncTTL._TTL.__contains__)
|
||||
del cls._rb_ttl.ttl[KEY((path,), {})]
|
||||
|
||||
@classmethod
|
||||
async def write_str(cls, path: str, content: str, encoding="utf-8") -> None:
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue