Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MemoryController

Internal storage for data, can hold any key/value collection.

Hierarchy

  • MemoryController

Indexable

[key: string]: any

Index signature allows any key value pair to be added to memory.

Index

Constructors

constructor

  • Create a memory instance for isolating users, key/value pairs. Create a memory instance for isolating users, key/value pairs.

    Returns MemoryController

Properties

private

private: object

Any misc data added without specifying collection.

Type declaration

  • [key: string]: any

rooms

rooms: object

All known rooms assigned to their ID as key.

Type declaration

  • [id: string]: Room

users

users: object

All known users assigned to their ID as key.

Type declaration

  • [id: string]: User

Methods

clear

  • clear(): void
  • Empty memory and start fresh with minimal empty collections.

    Returns void

clearSaveInterval

  • clearSaveInterval(): void
  • Stop saving data

    Returns void

get

  • get(key: string, collection?: undefined | string): any
  • Retrieve value from memory by key within given (or default) collection.

    Parameters

    • key: string
    • Optional collection: undefined | string

    Returns any

load

  • load(): Promise<void>
  • Update internal memory with any data set (mostly used on load)

    Returns Promise<void>

save

  • save(): Promise<void>
  • Save internal memory back to storage adapter (as memory type).

    Returns Promise<void>

set

  • set(key: string, value: any, collection?: undefined | string): this
  • Save key-value pair under the collection namespace, extend existing data. Set is used for temporal in-memory data for common interactions. For large data sets that will be infrequently accessed, use keep instead.

    Parameters

    • key: string
    • value: any
    • Optional collection: undefined | string

    Returns this

setSaveInterval

  • setSaveInterval(newInterval?: undefined | number): void
  • Save memory every x milliseconds

    Parameters

    • Optional newInterval: undefined | number

    Returns void

shutdown

  • shutdown(): Promise<void>
  • Save data and disconnect storage adapter

    Returns Promise<void>

start

  • start(): Promise<void>
  • Populate brian with temporal data from storage adapter and get started

    Returns Promise<void>

toObject

  • toObject(): any
  • Convert memory to an object with collection attributes.

    Returns any

unset

  • unset(key: string, collection?: undefined | string): this
  • Remove item from memory by key and collection namespace (optional).

    Parameters

    • key: string
    • Optional collection: undefined | string

    Returns this

Generated using TypeDoc