Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InMemoryDocStore

Simple implementation of ServerDocStore for demonstration purposes.

It stores all of its documents in memory only, hence is not reliable. But you can use its source code for guidance when implementing a proper, persistent ServerDocStore.

Hierarchy

  • InMemoryDocStore

Implements

Index

Constructors

Methods

  • addUpdate(docID: string, update: Uint8Array, updateType: number): Promise<null | string>
  • checkpoint(docID: string, savedState: Uint8Array, checkpointRequest: string): Promise<void>
  • Processes a checkpoint performed in response to a checkpointRequest from addUpdate.

    checkpoint is guaranteed to be at least as up-to-date as the saved state (previous checkpoint + uncompacted updates) at the end of the addUpdate call that returned checkpointRequest. So, it may replace any checkpoint and uncompacted updates older than that call.

    Implementer notes:

    • checkpointRequest may be out-of-date, i.e., we have saved a newer checkpoint since that request. In that case, this call should be ignored.
    • checkpointRequest is received over the network from a client and should be validated.

    Parameters

    • docID: string
    • savedState: Uint8Array
    • checkpointRequest: string

    Returns Promise<void>

  • load(docID: string): Promise<{ checkpoint: null | Uint8Array; updateTypes: number[]; updates: Uint8Array[] }>
  • Returns the current saved state of docID.

    As described in the class header, this state consists of a checkpoint plus uncompacted updates.

    The return value only needs to be up-to-date as of the time this call started, although it may be more up-to-date.

    If there is no saved state for docID, returns { checkpoint: null, updates: [], updateTypes: [] }.

    Parameters

    • docID: string

    Returns Promise<{ checkpoint: null | Uint8Array; updateTypes: number[]; updates: Uint8Array[] }>

Generated using TypeDoc