refactor: split main.py i moduler (config/cache/store/services/authentik) + async dashboard (TTFB ~6ms, indhold via /dashboard-content) + TTL-cache på Authentik-læsninger

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
agw
2026-06-11 21:50:00 +02:00
co-authored by Claude Opus 4.8
parent 19386698b5
commit 742d08c9fb
8 changed files with 509 additions and 495 deletions
+22
View File
@@ -0,0 +1,22 @@
"""Letvægts in-memory TTL-cache. Authentik-læsninger er I/O-bottleneck (ikke Python),
så vi cacher dem kort og rydder ved skrivninger."""
import time
_CACHE = {}
def get(key):
ent = _CACHE.get(key)
if ent and ent[0] > time.monotonic():
return ent[1]
return None
def put(key, val, ttl):
_CACHE[key] = (time.monotonic() + ttl, val)
def clear(*prefixes):
for k in list(_CACHE):
if not prefixes or any(k.startswith(p) for p in prefixes):
_CACHE.pop(k, None)