tachyon-drive
    Preparing search index...

    Class MemoryStorageDriver<Input, Output>

    A storage driver that stores data in memory.

    v0.6.0

    const driver: IStorageDriver<SomeType> = new MemoryStorageDriver<SomeType>('MemoryStorageDriver', serializer, null);
    

    Type Parameters

    • Input

      The type of the data to serialize and deserialize.

    • Output

      The type of the data to store.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    bandwidth: TachyonBandwidth = TachyonBandwidth.VeryLarge

    Indicates the speed of the storage driver.

    logger: MapLogger<StorageDriverLogMapping>
    name: string

    The name of the storage driver.

    Accessors

    • get isInitialized(): boolean

      Indicates whether or not the storage driver has been initialized.

      Returns boolean

    • get processor(): undefined | IStoreProcessor<Output>

      Get current processor

      Returns undefined | IStoreProcessor<Output>

      current processor

    Methods

    • Clear the stored data

      Returns Promise<void>

    • Clear the stored data and return the Promise of Result.

      Returns Promise<IResult<void>>

      A promise of Result that resolves when the data has been successfully cleared.

    • Clones the given data with the serializer.

      Parameters

      • data: Input

        The data to clone.

      Returns Input

      The cloned data.

    • Clone the given data with the serializer and return Result of the cloned data.

      Parameters

      • data: Input

        The data to clone.

      Returns IResult<Input>

      The cloned data.

    • Retrieves the processor for the storage driver if it is available.

      Returns Promise<undefined | IStoreProcessor<Output>>

      The processor for the storage driver, or undefined if no processor is available.

    • Retrieves the processor for the storage driver if it is available and returns the Promise of Result.

      Returns Promise<IResult<undefined | IStoreProcessor<Output>>>

      The processor for the storage driver, or undefined if no processor is available.

    • Clear the stored data in storage.

      Returns void

      A promise that resolves when the data has been successfully cleared.

    • Retrieve the data from storage.

      Returns undefined | Output

      A promise that resolves to the retrieved data, or undefined if no data was found.

    • Initialize the storage driver.

      Returns boolean

      A promise that resolves to true if the storage driver was successfully initialized, or false otherwise.

    • Store the given data to storage.

      Parameters

      Returns void

      A promise that resolves when the data has been successfully stored.

    • Called when the storage driver is unloaded.

      Returns boolean

      A promise that resolves to true if the storage driver was successfully unloaded, or false otherwise.

    • Use this to indicate that the data has been updated.

      Returns Promise<void>

    • Retrieves the data stored using the specified key.

      Parameters

      Returns Promise<undefined | Input>

      The retrieved data, or undefined if no data was found.

      An error if the data fails validation.

    • Retrieves the data stored using the specified key and returns the Promise of Result.

      Parameters

      • Optionaloptions: IHydrateOptions

        The options to use for hydrating the data.

      Returns Promise<IResult<undefined | Input>>

      Promise of Result that resolves to the retrieved data, or undefined if no data was found.

    • Initializes the storage driver.

      Returns Promise<boolean>

      A promise that resolves to true if the storage driver was successfully initialized, or false otherwise.

    • Initializes the storage driver and returns the Promise of Result.

      Returns Promise<IResult<boolean>>

      Promise of the result object, see Result

    • Set the data to store and emit an update.

      Parameters

      • data: undefined | Output

        The data to store.

      Returns Promise<void>

      A promise that resolves when the data has been successfully stored.

    • Stores the given data using the specified key.

      Parameters

      • data: Input

        The data to store.

      Returns Promise<void>

    • Stores the given data using the specified key and returns the Promise of Result.

      Parameters

      • data: Input

        The data to store.

      Returns Promise<IResult<void>>

      A promise of Result that resolves when the data has been successfully stored.

    • Build the default JSON representation of the storage driver.

      Returns StorageDriverJson

      The JSON representation of the storage driver.

      // override the toJSON method to include additional (typed) properties
      public override toJSON(): FooStorageDriverJson {
      return {
      ...super.toJSON(),
      foo: this.foo,
      };
      }
    • Returns a string representation of an object.

      Returns string

    • Unload the storage driver.

      Returns Promise<boolean>

      A promise that resolves to true if the storage driver was successfully unloaded, or false otherwise.

    • Unload the storage driver and return the Promise of Result.

      Returns Promise<IResult<boolean>>

      A promise of Result that resolves to true if the storage driver was successfully unloaded, or false otherwise.