Skip to main content
Module

x/grammy_menu/deps.deno.ts>MemorySessionStorage

Easily create interactive menus with grammY.
Go to Latest
class MemorySessionStorage
implements StorageAdapter<S>
import { MemorySessionStorage } from "https://deno.land/x/grammy_menu@v1.1.2/deps.deno.ts";

The memory session storage is a built-in storage adapter that saves your session data in RAM using a regular JavaScript Map object. If you use this storage adapter, all sessions will be lost when your process terminates or restarts. Hence, you should only use it for short-lived data that is not important to persist.

This class is used as default if you do not provide a storage adapter, e.g. to your database.

This storage adapter features expiring sessions. When instatiating this class yourself, you can pass a time to live in milliseconds that will be used for each session object. If a session for a user expired, the session data will be discarded on its first read, and a fresh session object as returned by the inital option (or undefined) will be put into place.

Constructors

new
MemorySessionStorage(timeToLive?: number)

Constructs a new memory session storage with the given time to live. Note that this storage adapter will not store your data permanently.

Properties

protected
readonly
storage: Map<string, { session: S; expires?: number; }>

Internally used Map instance that stores the session data

Methods

delete(key: string)
read(key: string)

Reads the values for all keys of the session storage, and returns them as an array.

write(key: string, value: S)