Skip to content

Commit 4eb4669

Browse files
committed
test(cache): add oversized cache key boundary test
1 parent 6ede310 commit 4eb4669

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/cache.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,20 @@ describe('TTLCache', () => {
487487

488488
cache.destroy();
489489
});
490+
491+
it('handles oversized cache keys safely', () => {
492+
const cache = new TTLCache<string>();
493+
494+
const oversizedKey = 'a'.repeat(20000);
495+
496+
expect(() => {
497+
cache.set(oversizedKey, 'large-key-value', 60_000);
498+
}).not.toThrow();
499+
500+
expect(cache.get(oversizedKey)).toBe('large-key-value');
501+
502+
cache.destroy();
503+
});
490504
});
491505
});
492506

0 commit comments

Comments
 (0)