Skip to content

Commit 3ae8721

Browse files
feat(cache): replace LruCache and TtlCache with unified Cache
Introduces a single `Cache` class that subsumes both `LruCache` and `TtlCache` into a configuration-driven API (maxSize, ttl, sliding expiration, stale-while-revalidate refresh, and onRemove). The new implementation delegates expiration tracking to `IndexedHeap` from `@std/data-structures/unstable-indexed-heap` for O(log n) evictions. - Add cache/cache.ts and cache/cache_test.ts - Remove cache/lru_cache.ts, cache/ttl_cache.ts and their tests - Update cache/memoize.ts doc to reference Cache - Update cache/mod.ts and cache/deno.json exports Made-with: Cursor
1 parent f318978 commit 3ae8721

10 files changed

Lines changed: 3283 additions & 1582 deletions

File tree

cache/cache.ts

Lines changed: 1260 additions & 0 deletions
Large diffs are not rendered by default.

cache/cache_test.ts

Lines changed: 2003 additions & 0 deletions
Large diffs are not rendered by default.

cache/deno.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"version": "0.2.3",
44
"exports": {
55
".": "./mod.ts",
6-
"./lru-cache": "./lru_cache.ts",
7-
"./memoize": "./memoize.ts",
8-
"./ttl-cache": "./ttl_cache.ts"
6+
"./cache": "./cache.ts",
7+
"./memoize": "./memoize.ts"
98
}
109
}

cache/lru_cache.ts

Lines changed: 0 additions & 362 deletions
This file was deleted.

0 commit comments

Comments
 (0)