tachyon-drive
    Preparing search index...

    Class StorageDriver<Input, Output>Abstract

    Abstract class that provides a simple interface for storing and retrieving data using a specified storage mechanism.

    v0.11.0

    Type Parameters

    • Input

      The type of the data to store and retrieve.

    • Output

      The type of the data to serialize and deserialize.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    • Creates a new instance of the StorageDriver class.

      Type Parameters

      • Input
      • Output

      Parameters

      • name: string

        The name of the storage driver.

      • serializer: IPersistSerializer<Input, Output>

        The serializer to use for serializing and deserializing data.

      • extNotify: null | IExternalNotify

        If driver does not support onUpdate, use this to notify with external event.

      • Optionalprocessor: Loadable<IStoreProcessor<Output>>

        The store processor to use for processing data before it is written to storage and after it is loaded from storage.

      • Optionallogger: ILoggerLike

        The logger to use for logging messages.

      Returns StorageDriver<Input, Output>

      An error if the serializer or processor is invalid.

    Properties

    bandwidth: TachyonBandwidth

    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

    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 | Promise<void>

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

    • Retrieve the data from storage.

      Returns undefined | Output | Promise<undefined | Output>

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

    • Initialize the storage driver.

      Returns boolean | Promise<boolean>

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

    • Store the given data to storage.

      Parameters

      • buffer: Output

        The data to store.

      Returns void | Promise<void>

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

    • Called when the storage driver is unloaded.

      Returns boolean | Promise<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

    • 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.