CacheEntry

Classin cache@fastly/js-compute 3.46.0since 3.9.0View source

Represents a cached item retrieved via CoreCache.lookup or as part of a TransactionCacheEntry.insertAndStreamBack operation.

Methods

age(): number

The current age in milliseconds of the cached item.

Returns

number

Retrieves the cached item as a ReadableStream.

Only one stream can be active at a time for a given CacheEntry. An error will be thrown if a stream is already active for this CacheEntry.

Parameters

options: CacheBodyOptionsoptional

Optional property used to request a range of bytes within the cached item.

Returns

close(): void

Closes the connection to the cache for this CacheEntry.

Returns

void
hits(): number

Determines the number of cache hits to this cached item.

Note: this hit count only reflects the view of the server that supplied the cached item. Due to clustering, this count may vary between potentially many servers within the data center where the item is cached. See the clustering documentation for details, though note that the exact caching architecture of Compute is different from VCL services.

Returns

number
length(): number | null

The size in bytes of the cached item, if known.

Returns

number | null

The length in bytes, or null if the length is currently unknown. The length may be unknown if the item is currently being streamed into the cache without a fixed length.

maxAge(): number

The time in milliseconds for which the cached item is considered fresh.

Returns

number

staleWhileRevalidate

View source
staleWhileRevalidate(): number

The time in milliseconds for which a cached item can safely be used despite being considered stale.

Returns

number
state(): CacheState

Returns a CacheState instance which reflects the current state of this CacheEntry instance.

Returns

userMetadata

View source
userMetadata(): ArrayBuffer

The user-controlled metadata associated with the cached item.

Returns