fix: extend OrgStructureCache TTL and add graceful shutdown cleanup

- Extended OrgStructureCache TTL from 10 to 30 minutes (reduce cleanup frequency)
- Added orgStructureCache.destroy() in graceful shutdown handler
- Updated documentation to reflect changes

Co-Authored-By: Claude (glm-4.7) <noreply@anthropic.com>
This commit is contained in:
Warunee Tamkoo 2026-01-29 00:05:56 +07:00
parent e4cfac2eb2
commit 7955c855bc
4 changed files with 18 additions and 5 deletions

View file

@ -5,7 +5,7 @@ interface CacheEntry {
class OrgStructureCache {
private cache: Map<string, CacheEntry> = new Map();
private readonly CACHE_TTL = 10 * 60 * 1000; // 10 minutes
private readonly CACHE_TTL = 30 * 60 * 1000; // 30 minutes
private isInitialized = false;
private cleanupTimer: NodeJS.Timeout | null = null;
@ -17,7 +17,7 @@ class OrgStructureCache {
if (this.isInitialized) return;
this.isInitialized = true;
// Cleanup expired entries every 10 minutes
// Cleanup expired entries every 30 minutes
this.cleanupTimer = setInterval(() => {
this.cleanup();
}, this.CACHE_TTL);