Class SimpleSyncRWTransaction

A simple RW transaction for simple synchronous key-value stores.

Hierarchy

  • SimpleSyncRWTransaction

Implements

Constructors

Properties

modifiedKeys: string[] = []

List of keys modified in this transaction, if any.

originalData: {
    [key: string]: Uint8Array | undefined;
} = {}

Stores data in the keys we modify prior to modifying them. Allows us to roll back commits.

Type declaration

  • [key: string]: Uint8Array | undefined

Methods

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

    Parameters

    • key: string

      The key to look under for data.

    Returns Uint8Array

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

  • Marks the given key as modified, and stashes its value if it has not been stashed already.

    Parameters

    • key: string

    Returns void

  • Adds the data to the store under the given key.

    Parameters

    • key: string

      The key to add the data under.

    • data: Uint8Array

      The data to add to the store.

    • overwrite: boolean

      If 'true', overwrite any existing data. If 'false', avoids storing the data if the key exists.

    Returns boolean

    True if storage succeeded, false otherwise.

  • Stashes given key value pair into originalData if it doesn't already exist. Allows us to stash values the program is requesting anyway to prevent needless get requests if the program modifies the data later on during the transaction.

    Parameters

    • key: string
    • value: Uint8Array

    Returns void

Generated using TypeDoc