0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

refactor(core): reduce cache ttl to 5s (#3516)

This commit is contained in:
Gao Sun 2023-03-20 09:30:45 +08:00 committed by GitHub
parent 69f563a056
commit d0a5537b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,10 @@ export type WellKnownCacheKey = (typeof cacheKeys)[number];
const buildKey = (tenantId: string, key: WellKnownCacheKey) => `${tenantId}:${key}` as const; const buildKey = (tenantId: string, key: WellKnownCacheKey) => `${tenantId}:${key}` as const;
class WellKnownCache { class WellKnownCache {
#cache = new TtlCache<string, unknown>(180_000 /* 3 minutes */); // This TTL should be very small since the sign-in experiences will be unusable
// if requests hit different instances during the cache-hit period.
// We need to use a real central cache like Redis with invalidation mechanism for it.
#cache = new TtlCache<string, unknown>(5000);
/** /**
* Use for centralized well-known data caching. * Use for centralized well-known data caching.