file on
an interval and when the bot stops. It is the default store. It keeps the newest 1000 messages
per chat unless maxMessagesPerChat says otherwise. For a database, use
@botmesh/sqlite-store or @botmesh/redis-store.
Example
Implements
Constructors
Constructor
Parameters
Returns
MemoryStore
Methods
start()
Returns
Promise<void>
Implementation of
IStore.start
stop()
Returns
Promise<void>
Implementation of
IStore.stop
saveMessage()
Parameters
Returns
Promise<void>
Implementation of
IStore.saveMessage
getMessage()
Parameters
Returns
Promise<StoredMessage | undefined>
Implementation of
IStore.getMessage
getMessagesByChat()
Parameters
Returns
Promise<StoredMessage[]>
Implementation of
IStore.getMessagesByChat
deleteMessage()
Parameters
Returns
Promise<void>
Implementation of
IStore.deleteMessage
upsertChat()
chat onto the stored record. An own field set to undefined UNSETS
that field, so a partial upsert must omit what it does not know (the Bot does).
Parameters
Returns
Promise<void>
Implementation of
IStore.upsertChat
getChat()
Parameters
Returns
Promise<StoredChat | undefined>
Implementation of
IStore.getChat
listChats()
Returns
Promise<StoredChat[]>
Implementation of
IStore.listChats
deleteChat()
Parameters
Returns
Promise<void>
Implementation of
IStore.deleteChat
upsertContact()
contact onto the stored record; same undefined = unset rule as upsertChat.
Parameters
Returns
Promise<void>
Implementation of
IStore.upsertContact
getContact()
Parameters
Returns
Promise<StoredContact | undefined>
Implementation of
IStore.getContact
listContacts()
Returns
Promise<StoredContact[]>
Implementation of
IStore.listContacts
deleteContact()
Parameters
Returns
Promise<void>
Implementation of
IStore.deleteContact
getCursor()
Parameters
Returns
Promise<string | undefined>
Implementation of
IStore.getCursor
setCursor()
Parameters
Returns
Promise<void>
Implementation of
IStore.setCursor
getCheckpoint()
Parameters
Returns
Promise<FlowCheckpoint | undefined>
Implementation of
IStore.getCheckpoint
setCheckpoint()
Parameters
Returns
Promise<void>
Implementation of
IStore.setCheckpoint
clearCheckpoint()
Parameters
Returns
Promise<void>
Implementation of
IStore.clearCheckpoint
setCheckpointIf()
IStore.setCheckpointIf): one synchronous step, so concurrent callers see one winner.
Parameters
Returns
Promise<boolean>
Implementation of
IStore.setCheckpointIf
clearCheckpointIf()
true when the row is absent, or its revision (0 without one)
matched expectedRevision and it was deleted; false when a different revision is
stored (the row is left untouched). Same atomicity rule as setCheckpointIf.
Parameters
Returns
Promise<boolean>
Implementation of
IStore.clearCheckpointIf
listCheckpoints()
Returns
Promise<[string, FlowCheckpoint][]>
Implementation of
IStore.listCheckpoints
getConversation()
Parameters
Returns
Promise<AIMessage[] | undefined>
Implementation of
IStore.getConversation
setConversation()
Parameters
Returns
Promise<void>
Implementation of
IStore.setConversation
clearConversation()
Parameters
Returns
Promise<void>
Implementation of
IStore.clearConversation
getUserData()
undefined when the entry is missing OR its
expiresAt is <= Date.now() (lazy expiry — expired rows may still exist
physically until purged).
Parameters
Returns
Promise<UserDataEntry | undefined>
Implementation of
IStore.getUserData
setUserData()
value and
expiresAt (no read-modify-write inside the store). An entry whose
expiresAt is already in the past may be dropped instead of written.
Parameters
Returns
Promise<void>
Implementation of
IStore.setUserData
deleteUserData()
namespace + key), one whole namespace (key omitted)
or every namespace of the user (namespace omitted; key is then ignored).
Deleting missing data is a no-op.
Parameters
Returns
Promise<void>
Implementation of
IStore.deleteUserData
listUserData()
namespace. Order unspecified.
Parameters
Returns
Promise<UserDataEntry[]>
Implementation of
IStore.listUserData
purgeExpiredUserData()
expiresAt <= now (default Date.now())
across the whole store; resolves with how many were removed. Stores with
native expiry (Redis) resolve 0.
Parameters
Returns
Promise<number>
Implementation of
IStore.purgeExpiredUserData
Accessors
durable
Get Signature
true when this store mirrors itself to a JSON file, so its data (including
persistent() flow checkpoints) survives a process restart. false = RAM only.
Returns
boolean