SessionCacheStrategy
SessionCacheStrategy
This strategy defines how sessions get cached. Since most requests will need the Session object for permissions data, it can become a bottleneck to go to the database and do a multi-join SQL query each time. Therefore we cache the session data only perform the SQL query once and upon invalidation of the cache.
Signature
interface SessionCacheStrategy extends InjectableStrategy {
set(session: CachedSession): void | Promise<void>;
get(sessionToken: string): CachedSession | undefined | Promise<CachedSession | undefined>;
delete(sessionToken: string): void | Promise<void>;
clear(): void | Promise<void>;
}
Extends
Members
set
(session: CachedSession) => void | Promise<void>
get
(sessionToken: string) => CachedSession | undefined | Promise<CachedSession | undefined>
delete
(sessionToken: string) => void | Promise<void>
clear
() => void | Promise<void>
CachedSessionUser
A simplified representation of the User associated with the current Session.
Signature
type CachedSessionUser = {
id: ID;
identifier: string;
verified: boolean;
channelPermissions: UserChannelPermissions[];
}
Members
id
ID
identifier
string
verified
boolean
channelPermissions
UserChannelPermissions[]
CachedSession
A simplified representation of a Session which is easy to store.
Signature
type CachedSession = {
cacheExpiry: number;
id: ID;
token: string;
expires: Date;
activeOrderId?: ID;
authenticationStrategy?: string;
user?: CachedSessionUser;
activeChannelId?: ID;
}
Members
cacheExpiry
number
sessionCacheTTL
option.
id
ID
token
string
expires
Date
activeOrderId
ID
authenticationStrategy
string
user
CachedSessionUser
activeChannelId
ID