Cache more forgejo-authentication source queries #172
3 changed files with 16 additions and 3 deletions
10
CHANGELOG.md
10
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
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = '5.2.0'
|
||||
__version__ = '5.2.1'
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue