The source of a 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 ReadableStream( new CachableSource<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 ReadableStream( new CachableSource<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 source = new CachableSource<number>( cache, ['numbers'], () => ++i)const stream = new ReadableStream(source)stream.pipeTo(write(console.info))// 1source.clear()// 2 Copy
const cache = new StorageCache( localStorage, 'my-cache', 30 * 60_000)let i = 0const source = new CachableSource<number>( cache, ['numbers'], () => ++i)const stream = new ReadableStream(source)stream.pipeTo(write(console.info))// 1source.clear()// 2
Private
Readonly
Generated using TypeDoc
The source of a
ReadableStream
that queues items only when a timed cache becomes invalid.See
Example
Caching for 30 minutes.
Example
Manually clearing cache.