diff --git a/edge-script/index.ts b/edge-script/index.ts index 8fa0be4..065e7f5 100644 --- a/edge-script/index.ts +++ b/edge-script/index.ts @@ -21,7 +21,8 @@ interface CacheEntry { } const cache = new Map(); -const CACHE_TTL_MS = 60_000; +const CACHE_TTL_BLOCKED_MS = 60_000; // 차단 IP: 1분 (빠른 해제 반영) +const CACHE_TTL_CLEAN_MS = 300_000; // 정상 IP: 5분 (DB 부하 감소) const CACHE_MAX_SIZE = 50_000; function cacheGet(ip: string): boolean | null { @@ -44,7 +45,8 @@ function cacheSet(ip: string, blocked: boolean): void { // If still too large, clear entirely if (cache.size >= CACHE_MAX_SIZE) cache.clear(); } - cache.set(ip, { blocked, expiresAt: Date.now() + CACHE_TTL_MS }); + const ttl = blocked ? CACHE_TTL_BLOCKED_MS : CACHE_TTL_CLEAN_MS; + cache.set(ip, { blocked, expiresAt: Date.now() + ttl }); } // ---------------------------------------------------------------------------