RedisSessionStore
The SessionStore on Redis.
Implements
Section titled “Implements”SessionStore
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RedisSessionStore(
redis,options?):RedisSessionStore
Parameters
Section titled “Parameters”Redis
options?
Section titled “options?”Returns
Section titled “Returns”RedisSessionStore
Properties
Section titled “Properties”epochTtlMs
Section titled “epochTtlMs”
readonlyepochTtlMs:number
How long a user’s epoch outlives its last write; createAuth refuses a device token that is not a clock skew shorter.
Implementation of
Section titled “Implementation of”SessionStore.epochTtlMs
maxSessionTtlMs
Section titled “maxSessionTtlMs”
readonlymaxSessionTtlMs:number
The longest session this store guards; createAuth refuses a longer remember-me TTL.
Implementation of
Section titled “Implementation of”SessionStore.maxSessionTtlMs
Methods
Section titled “Methods”bumpEpoch()
Section titled “bumpEpoch()”bumpEpoch(
userId):Promise<number>
Atomically increments and returns the epoch. Its TTL must outlive every session.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”SessionStore.bumpEpoch
create()
Section titled “create()”create(
session,ttlMs):Promise<void>
Stores the session with a TTL of ttlMs and indexes it under its user.
Parameters
Section titled “Parameters”session
Section titled “session”StoredSession
number
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”SessionStore.create
delete()
Section titled “delete()”delete(
userId,ids):Promise<string[]>
Deletes the sessions and removes them from the user’s index. Should return the ids this call removed (the ones that still existed), so that of concurrent deletes of one session exactly one reports it: the per-user cap reports evictions from it. A store that returns nothing is taken to have removed every id it was given, and racing evictions may then report a session twice.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
readonly string[]
Returns
Section titled “Returns”Promise<string[]>
Implementation of
Section titled “Implementation of”SessionStore.delete
epochTtlRemaining()
Section titled “epochTtlRemaining()”epochTtlRemaining(
userId):Promise<number>
Remaining TTL of the user’s epoch in ms (-2 when absent).
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<number>
get(
id):Promise<StoredSession<unknown> |null>
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<StoredSession<unknown> | null>
Implementation of
Section titled “Implementation of”SessionStore.get
getEpoch()
Section titled “getEpoch()”getEpoch(
userId):Promise<number>
The user’s revocation epoch; 0 when never bumped.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”SessionStore.getEpoch
listByUser()
Section titled “listByUser()”listByUser(
userId):Promise<StoredSession<unknown>[]>
The user’s sessions that still exist (expired ones are not returned).
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<StoredSession<unknown>[]>
Implementation of
Section titled “Implementation of”SessionStore.listByUser
touch()
Section titled “touch()”touch(
session):Promise<boolean>
Replaces the stored value ONLY IF the session still exists, keeping its
TTL (Redis: SET ... XX KEEPTTL). Returns false when it is gone. Must
never recreate a deleted session, even when racing a delete.
Parameters
Section titled “Parameters”session
Section titled “session”StoredSession
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”SessionStore.touch