An extension to the ReadableStream that queues items only when a timed cache becomes invalid.
ReadableStream
Caching for 30 minutes.
const cache = new StorageCache( localStorage, 'my-cache', 30 * 60_000)let i = 0const stream = new CachableStream<number>( cache, ['numbers'], () => ++i)stream.pipeTo(write(console.info))// 1await setTimeout(30 * 60_000))// 2 Copy
const cache = new StorageCache( localStorage, 'my-cache', 30 * 60_000)let i = 0const stream = new CachableStream<number>( cache, ['numbers'], () => ++i)stream.pipeTo(write(console.info))// 1await setTimeout(30 * 60_000))// 2
Manually clearing cache.
const cache = new StorageCache( localStorage, 'my-cache', 30 * 60_000)let i = 0const stream = new CachableStream<number>( cache, ['numbers'], () => ++i)stream.pipeTo(write(console.info))// 1stream.clear()// 2 Copy
const cache = new StorageCache( localStorage, 'my-cache', 30 * 60_000)let i = 0const stream = new CachableStream<number>( cache, ['numbers'], () => ++i)stream.pipeTo(write(console.info))// 1stream.clear()// 2
Private
Readonly
Optional
Generated using TypeDoc
An extension to the
ReadableStream
that queues items only when a timed cache becomes invalid.See
Example
Caching for 30 minutes.
Example
Manually clearing cache.