PendingTransaction

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

A transactional cache lookup issued via CoreCache.transactionLookupAsync that has not yet resolved.

Constructor

new PendingTransaction()

Methods

pending(): boolean

Returns true if the transaction lookup has not yet resolved.

This is a non-blocking check, and can be called any number of times before wait() is called.

Returns

boolean
wait(timeoutMs?: number): Promise<TransactionCacheEntry>

Waits for the transaction lookup to resolve, returning a TransactionCacheEntry — the same value that CoreCache.transactionLookup() would have returned had it been called instead.

If timeoutMs is provided and the lookup does not resolve within that many milliseconds, the returned promise rejects, and the pending lookup is released so that it no longer holds up e.g. other transactional lookups for the same key.

wait() can only be called once per PendingTransaction; calling it again throws.

Parameters

timeoutMs: numberoptional

The maximum number of milliseconds to wait for the lookup to resolve.

Returns

Throws

  • If timeoutMs elapses before the lookup resolves, or if wait() has already been called on this PendingTransaction.