mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-02 20:32:19 +00:00
fix(login): replace custom SWR cache with lru-cache (#11945)
# Which Problems Are Solved
The in-memory SWR promiseCache in zitadel.ts used keys like
getBrandingSettings-${org} that had no instance identifier. In
multi-tenant mode, where a single Next.js process serves multiple
instances, an instance A's cached settings without org context
(branding, languages, settings, etc.) could be served to Instance B
request without org context. The cache now additionally is bound to 100
entries by default (configurable via maxSize in `API_CACHE_CONFIG`).
When capacity is exceeded, expired entries are swept first
It additionally replaces the hand-rolled PromiseCache (Map-based, FIFO
eviction) with lru-cache, leveraging its built-in fetchMethod for
stale-while-revalidate, request deduplication, and true LRU eviction.
# How the Problems Are Solved
Added an instanceCacheKey() helpe that prefixes every cache key with
serviceConfig.instanceHost in addition to the org context if available.
---------
Co-authored-by: Ramon <[email protected]>
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
"copy-to-clipboard": "^3.3.3",
|
||||
"deepmerge": "^4.3.1",
|
||||
"escape-html": "^1.0.3",
|
||||
"lru-cache": "^11.3.2",
|
||||
"lucide-react": "^0.577.0",
|
||||
"moment": "^2.30.1",
|
||||
"next": "16.2.2",
|
||||
|
||||
Reference in New Issue
Block a user