Dual Window Cache (DWC) is a high-performance constant-time cache algorithm in TypeScript/JavaScript, implemented in the dw-cache npm package at version 0.0.120. It claims the highest engineering hit ratio among general-purpose caching algorithms by using only two lists for low overhead and latency, with resistance to scan, loop, and burst access patterns. Unlike LIRS or TinyLFU, DWC avoids batch processing, linear-time operations, and excessive memory overhead. It ships with TypeScript types and is actively maintained. Recommended for cache sizes above 200 entries (ideally 5,000+) for optimal statistical precision. The package is a standalone implementation of the DWC algorithm, now maintained as part of the spica monorepo.
npm install dw-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic cache operations: construction with limit, get/set/has/del, iteration over keys in MRU order, and clear.
Always pass a limit > 0: new Cache({ limit: 1000 })Watch https://github.com/falsandtru/spica for migration instructions.
Implement your own TTL wrapper or use a different caching library if TTL is required.
Treat iteration order as informational only; avoid order-dependent algorithms.
Run 'npm install dw-cache' and ensure import uses: import { Cache } from 'dw-cache'Change to: import { Cache } from 'dw-cache'Pass { limit: 1000 } (or any positive integer) to the constructor.No dependency data recorded yet.