Skip to main content

Class: MemoryByteCache

Defined in: memory-cache.ts:44

The default ByteCache: contiguous spans in memory, looked up by containment, with one LRU budget per Purpose so data churn can never evict metadata spans. A read is served from any span that contains it, whichever purpose fetched it; the purpose only decides which budget a stored span counts against. A span larger than its budget, or empty, is not stored. A span contained in a stored span is dropped; stored spans the new span contains are replaced by it. Partial overlaps are kept side by side and are misses for a read that straddles them.

Implements​

Constructors​

Constructor​

new MemoryByteCache(options?): MemoryByteCache

Defined in: memory-cache.ts:49

Parameters​

options?​
dataBytes?​

number

metadataBytes?​

number

Returns​

MemoryByteCache

Methods​

byteSize()​

byteSize(purpose): number

Defined in: memory-cache.ts:135

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

Parameters​

purpose​

Purpose

Returns​

number

Implementation of​

ByteCache.byteSize


delete()​

delete(file): Promise<void>

Defined in: memory-cache.ts:139

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>

Implementation of​

ByteCache.delete


get()​

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

Defined in: memory-cache.ts:56

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

Parameters​

file​

FileIdentity

range​

ByteRange

_purpose​

Purpose

Returns​

Promise<Uint8Array<ArrayBufferLike> | undefined>

Implementation of​

ByteCache.get


put()​

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

Defined in: memory-cache.ts:82

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>

Implementation of​

ByteCache.put