Class AsyncTransaction<T>Abstract

Transaction that implements synchronous operations with a cache Implementors: You must update the cache and wait for store.asyncDone in your asynchronous methods.

Make sure we handle abortions correctly, especially since the cache is shared between transactions.

Type Parameters

Hierarchy (View Summary)

Constructors

Properties

asyncDone: Promise<unknown> = ...
store: T

Methods

  • Internal

    Gets a cache resource If info is set and the resource doesn't exist, it will be created

    Parameters

    • id: number
    • Optionalinfo: { size: number }

    Returns undefined | Resource<number>

  • Internal

    Run a asynchronous operation from a sync context. Not magic and subject to (race) conditions.

    Parameters

    • promise: Promise<unknown>

    Returns void

  • Retrieves data.

    Parameters

    • id: number

      The key to look under for data.

    • offset: number
    • Optionalend: number

    Returns Promise<undefined | Uint8Array<ArrayBufferLike>>

  • Retrieves data. Throws an error if an error occurs or if the key does not exist.

    Parameters

    • id: number

      The key to look under for data.

    • offset: number
    • Optionalend: number

    Returns undefined | Uint8Array<ArrayBufferLike>

    The data stored under the key, or undefined if not present.

  • Adds the data to the store under an id. Overwrites any existing data.

    Parameters

    • id: number

      The key to add the data under.

    • data: Uint8Array

      The data to add to the store.

    • offset: number

    Returns Promise<void>

  • Adds the data to the store under and id.

    Parameters

    • id: number

      The key to add the data under.

    • data: Uint8Array

      The data to add to the store.

    • offset: number

    Returns void