An IndexedDbCache instance acts as the counterpart of an IndexedDbCache Component in Unity. When the Component is started in Unity, an instance of this class is created by UnityUtil and attached to the unityInstance. This reference is used by functions in the indexedDb.jslib plug-in in Unity to make calls directly from the viewer. This class receives requests to create transactions against IndexedDb, and returns their results through SendMessage. In practice, IndexedDb operations are offloaded to a WebWorker, so this implementation is primarily used to maintain the worker and translate between it and Unity.

Hierarchy

  • IndexedDbCache

Constructors

Properties

gameObjectName: string

The gameObject which should be passed to SendMessage when making the callbacks to the viewer

host: URL

The host on which to find the WebWorker script.

transactions: any

Resources for in-progress get requests

unityInstance: any

The Unity Instance created by the loader; this is used for SendMessage

worker: any

The WebWorker that handles the IndexedDb requests. Each instance of this class gets its own worker.

Methods

  • Requests data from the database with the specified key. In practice, the worker will maintain a local memory cache, but the implementation is invisible from this side. The id is used to reference this specific transaction between calls to createGetTransaction, getTransactionData & releaseTransaction. Multiple transactions may access the the same key but may not share an id.

    Parameters

    • id: number
    • key: string

    Returns void

  • Requests data be inserted into the database with a put request.

    Parameters

    • id: number
    • key: string
    • offset: number
    • size: number

    Returns void

  • Copies the data returned from a get request into the heap at offset. Once this is done the local resources should be released by calling releaseTransaction.

    Parameters

    • id: number
    • offset: number

    Returns void

  • Releases any resources associated with an existing transaction or Db operation. Not all oprations will have resources. If an invalid id is passed in, this method does nothing.

    Parameters

    • id: number

      The transaction id whose resources to dispose of

    Returns void

Generated using TypeDoc