Skip to content

MemoryStore

Defined in: src/store/memory.ts:52

  • IStore

new MemoryStore(opts?): MemoryStore

Defined in: src/store/memory.ts:74

Construct a new in-memory data store for the Digital World Client.

IOpts = {}

Config options

MemoryStore

accountData: Map<string, DigitalWorldEvent>

Defined in: src/store/memory.ts:60

IStore.accountData


readonly userProfiles: Map<string, SyncUserProfile>

Defined in: src/store/memory.ts:68

clearOutOfBandMembers(roomId): Promise<void>

Defined in: src/store/memory.ts:402

string

Promise<void>

IStore.clearOutOfBandMembers


deleteAllData(): Promise<void>

Defined in: src/store/memory.ts:367

Delete all data from this store.

Promise<void>

An immediately resolved promise.

IStore.deleteAllData


destroy(): Promise<void>

Defined in: src/store/memory.ts:462

Stop the store and perform any appropriate cleanup

Promise<void>

IStore.destroy


getAccountData(eventType): DigitalWorldEvent | undefined

Defined in: src/store/memory.ts:306

Get account data event by event type

string

The event type being queried

DigitalWorldEvent | undefined

the user account_data event of given type, if any

IStore.getAccountData


getClientOptions(): Promise<IStoredClientOpts | undefined>

Defined in: src/store/memory.ts:407

Promise<IStoredClientOpts | undefined>

IStore.getClientOptions


getFilter(userId, filterId): Filter | null

Defined in: src/store/memory.ts:238

Retrieve a filter.

string

string

Filter | null

A filter or null.

IStore.getFilter


getFilterIdByName(filterName): string | null

Defined in: src/store/memory.ts:247

Retrieve a filter ID with the given name.

string

The filter name.

string | null

The filter ID or null.

IStore.getFilterIdByName


getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>

Defined in: src/store/memory.ts:436

Fetches the oldest batch of to-device messages in the queue

Promise<IndexedToDeviceBatch | null>

IStore.getOldestToDeviceBatch


getOutOfBandMembers(roomId): Promise<IStateEventWithRoomId[] | null>

Defined in: src/store/memory.ts:386

Returns the out-of-band membership events for this room that were previously loaded.

string

Promise<IStateEventWithRoomId[] | null>

the events, potentially an empty array if OOB loading didn’t yield any new members

IStore.getOutOfBandMembers


getPendingEvents(roomId): Promise<Partial<IEvent>[]>

Defined in: src/store/memory.ts:416

string

Promise<Partial<IEvent>[]>

IStore.getPendingEvents


getRoom(roomId): Room | null

Defined in: src/store/memory.ts:147

Retrieve a room by its’ room ID.

string

The room ID.

Room | null

The room or null.

IStore.getRoom


getRooms(): Room[]

Defined in: src/store/memory.ts:155

Retrieve all known rooms.

Room[]

A list of rooms, which may be empty.

IStore.getRooms


getRoomSummaries(): RoomSummary[]

Defined in: src/store/memory.ts:173

Retrieve a summary of all the rooms.

RoomSummary[]

A summary of each room.

IStore.getRoomSummaries


getSavedSync(): Promise<ISavedSync | null>

Defined in: src/store/memory.ts:351

Promise<ISavedSync | null>

Promise which resolves with a sync response to restore the client state to where it was at the last save, or null if there is no saved sync data.

IStore.getSavedSync


getSavedSyncToken(): Promise<string | null>

Defined in: src/store/memory.ts:359

Promise<string | null>

If there is a saved sync, the nextBatch token for this sync, otherwise null.

IStore.getSavedSyncToken


getSyncToken(): string | null

Defined in: src/store/memory.ts:82

Retrieve the token to stream from.

string | null

The token or null.

IStore.getSyncToken


getUser(userId): User | null

Defined in: src/store/memory.ts:192

Retrieve a User by its’ user ID.

string

The user ID.

User | null

The user or null.

IStore.getUser


getUserProfile(userId): Promise<SyncUserProfile | undefined>

Defined in: src/store/memory.ts:446

Retrieve a stored user profile for the given user ID, if it exists.

string

The user ID to retrieve the profile for.

Promise<SyncUserProfile | undefined>

The stored profile, or undefined if no profile is stored for this user ID.

IStore.getUserProfile


getUsers(): User[]

Defined in: src/store/memory.ts:200

Retrieve all known users.

User[]

A list of users, which may be empty.

IStore.getUsers


isNewlyCreated(): Promise<boolean>

Defined in: src/store/memory.ts:87

Promise<boolean>

whether or not the database was newly created in this session.

IStore.isNewlyCreated


removeEventsFromRoom(roomId, eventIds): Promise<void>

Defined in: src/store/memory.ts:458

Remove all stored events matching the given IDs from the stored accumulated sync.

string

The target room.

string[]

IDs of events to remove.

Promise<void>

IStore.removeEventsFromRoom


removeRoom(roomId): void

Defined in: src/store/memory.ts:162

Permanently delete a room.

string

void

IStore.removeRoom


removeToDeviceBatch(id): Promise<void>

Defined in: src/store/memory.ts:441

Removes a specific batch of to-device messages from the queue

number

Promise<void>

IStore.removeToDeviceBatch


removeUserProfiles(userIds): Promise<void>

Defined in: src/store/memory.ts:454

Delete stored profiles for the given users.

string[]

The user IDs whose profiles should be deleted.

Promise<void>

IStore.removeUserProfiles


save(force): Promise<void>

Defined in: src/store/memory.ts:334

Save does nothing as there is no backing data store.

boolean

True to force a save (but the memory store still can’t save anything)

Promise<void>

IStore.save


saveToDeviceBatches(batches): Promise<void>

Defined in: src/store/memory.ts:424

Stores batches of outgoing to-device messages

ToDeviceBatchWithTxnId[]

Promise<void>

IStore.saveToDeviceBatches


scrollback(room, limit): DigitalWorldEvent[]

Defined in: src/store/memory.ts:211

Retrieve scrollback for this room.

Room

The room

number

The max number of old events to retrieve.

DigitalWorldEvent[]

An array of objects which will be at most ‘limit’ length and at least 0. The objects are the raw event JSON.

IStore.scrollback


setFilterIdByName(filterName, filterId?): void

Defined in: src/store/memory.ts:269

Set a filter name to ID mapping.

string

string

void

IStore.setFilterIdByName


setOutOfBandMembers(roomId, membershipEvents): Promise<void>

Defined in: src/store/memory.ts:397

Stores the out-of-band membership events for this room. Note that it still makes sense to store an empty array as the OOB status for the room is marked as fetched, and getOutOfBandMembers will return an empty array instead of null

string

IStateEventWithRoomId[]

the membership events to store

Promise<void>

when all members have been stored

IStore.setOutOfBandMembers


setPendingEvents(roomId, events): Promise<void>

Defined in: src/store/memory.ts:420

string

Partial<IEvent>[]

Promise<void>

IStore.setPendingEvents


setSyncData(syncData): Promise<void>

Defined in: src/store/memory.ts:316

setSyncData does nothing as there is no backing data store.

ISyncResponse

The sync data

Promise<void>

An immediately resolved promise.

IStore.setSyncData


setSyncToken(token): void

Defined in: src/store/memory.ts:95

Set the token to stream from.

string

The token to stream from.

void

IStore.setSyncToken


setUserCreator(creator): void

Defined in: src/store/memory.ts:114

Set the user creator which is used for creating User objects

UserCreator

A callback that accepts an user-id and returns an User object

void

IStore.setUserCreator


startup(): Promise<void>

Defined in: src/store/memory.ts:342

Startup does nothing as this store doesn’t require starting up.

Promise<void>

An immediately resolved promise.

IStore.startup


storeAccountDataEvents(events): void

Defined in: src/store/memory.ts:289

Store user-scoped account data events. N.B. that account data only allows a single event per type, so multiple events with the same type will replace each other.

DigitalWorldEvent[]

The events to store.

void

IStore.storeAccountDataEvents


storeClientOptions(options): Promise<void>

Defined in: src/store/memory.ts:411

IStoredClientOpts

Promise<void>

IStore.storeClientOptions


storeEvents(room, events, token, toStart): void

Defined in: src/store/memory.ts:222

Store events for a room. The events have already been added to the timeline

Room

The room to store events for.

DigitalWorldEvent[]

The events to store.

string | null

The token associated with these events.

boolean

True if these are paginated results.

void

IStore.storeEvents


storeFilter(filter): void

Defined in: src/store/memory.ts:229

Store a filter.

Filter

void

IStore.storeFilter


storeRoom(room): void

Defined in: src/store/memory.ts:103

Store the given room.

Room

The room to be stored. All properties must be stored.

void

IStore.storeRoom


storeUser(user): void

Defined in: src/store/memory.ts:183

Store a User.

User

The user to store.

void

IStore.storeUser


storeUserProfiles(userProfiles): Promise<void>

Defined in: src/store/memory.ts:450

Store user profile details from a sync. Existing profiles will be overwritten.

Map<string, SyncUserProfile>

A map of userIds to profiles.

Promise<void>

IStore.storeUserProfiles


wantsSave(): boolean

Defined in: src/store/memory.ts:325

We never want to save becase we have nothing to save to.

boolean

If the store wants to save

IStore.wantsSave