diff --git a/CHANGELOG.md b/CHANGELOG.md index bc320ba..545f9f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 5.2.1 (2025-11-26) + +## Changes + +- Improve caching in Forgejo authentication sources. All calls to a + Forgejo-authentication source are now cached with expiration duration + between one and five minutes. Authentication-related changes in Forgejo + instances might therefore become visible after up to five minutes. + + # 5.2.0 (2025-10-29) ## New features diff --git a/dump_things_service/__about__.py b/dump_things_service/__about__.py index f279ec9..4dc2ef2 100644 --- a/dump_things_service/__about__.py +++ b/dump_things_service/__about__.py @@ -1 +1 @@ -__version__ = '5.2.0' +__version__ = '5.2.1' diff --git a/dump_things_service/auth/forgejo.py b/dump_things_service/auth/forgejo.py index 36b475b..41b5d37 100644 --- a/dump_things_service/auth/forgejo.py +++ b/dump_things_service/auth/forgejo.py @@ -43,9 +43,9 @@ class MethodCache: @staticmethod def cache_temporary( - duration: int = 3600, + duration: int = 300, ) -> Callable: - """ Cache results for a given time (default: 3600 seconds) """ + """ Cache results for a given time (default: 300 seconds) """ def decorator(func: Callable) -> Callable: @wraps(func) def wrapper(*args, **kwargs): @@ -132,6 +132,7 @@ class ForgejoAuthenticationSource(AuthenticationSource, MethodCache): raise InvalidTokenError(msg) return r.json() + @MethodCache.cache_temporary(duration=120) def _get_user( self, token: str, @@ -145,6 +146,7 @@ class ForgejoAuthenticationSource(AuthenticationSource, MethodCache): token, ) + @MethodCache.cache_temporary(duration=120) def _get_teams_for_user(self, token: str) -> dict: r = self._get_json_from_endpoint('user/teams', token) return {team['name']: team for team in r} @@ -208,6 +210,7 @@ class ForgejoAuthenticationSource(AuthenticationSource, MethodCache): ) return permissions + @MethodCache.cache_temporary(duration=60) def authenticate( self, token: str,