Skip to main content

Interface: ByteCache

Defined in: types.ts:87

Where received byte spans live. The default is MemoryByteCache; a user can supply a disk-backed one. Both methods are asynchronous so a cache can live outside memory. A cache only holds bytes: in-flight requests and the not-found outcome stay in the reader.

Methods​

byteSize()?​

optional byteSize(purpose): number

Defined in: types.ts:102

Bytes currently held for purpose, when the cache can tell.

Parameters​

purpose​

Purpose

Returns​

number


delete()?​

optional delete(file): Promise<void>

Defined in: types.ts:108

Drop every span of file. The reader calls this when a response shows the object was replaced, so a cache without it keeps serving the old bytes after a change.

Parameters​

file​

FileIdentity

Returns​

Promise<void>


get()​

get(file, range, purpose): Promise<Uint8Array<ArrayBufferLike> | undefined>

Defined in: types.ts:89

The bytes of range if one stored span contains all of it.

Parameters​

file​

FileIdentity

range​

ByteRange

purpose​

Purpose

Returns​

Promise<Uint8Array<ArrayBufferLike> | undefined>


put()​

put(file, offset, bytes, purpose): Promise<void>

Defined in: types.ts:95

Store a received span. The cache decides what to keep and for how long.

Parameters​

file​

FileIdentity

offset​

number

bytes​

Uint8Array

purpose​

Purpose

Returns​

Promise<void>