Skip to content

Commit eae5a04

Browse files
committed
fix: ensure isFresh function correctly handles non-positive TTL values
1 parent 74aaf15 commit eae5a04

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/lib/db/cache.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function isCacheEntry(value: unknown): value is CacheEntry<unknown> {
3939
}
4040

4141
function isFresh(entry: CacheEntry<unknown>, ttlMs: number): boolean {
42+
if (ttlMs <= 0) return false;
43+
4244
const age = Date.now() - entry.storedAt;
4345
return Number.isFinite(entry.storedAt) && age >= 0 && age <= ttlMs;
4446
}

0 commit comments

Comments
 (0)