Procházet zdrojové kódy

docs(core): Add TTL to example Redis session cache strategy

Michael Bromley před 2 roky
rodič
revize
78be541eaa

+ 2 - 1
packages/core/src/config/session-cache/session-cache-strategy.ts

@@ -69,6 +69,7 @@ export type CachedSession = {
  * }
  * const loggerCtx = 'RedisSessionCacheStrategy';
  * const DEFAULT_NAMESPACE = 'vendure-session-cache';
+ * const DEFAULT_TTL = 86400;
  *
  * export class RedisSessionCacheStrategy implements SessionCacheStrategy {
  *   private client: Redis;
@@ -100,7 +101,7 @@ export type CachedSession = {
  *
  *   async set(session: CachedSession) {
  *     try {
- *       await this.client.set(this.namespace(session.token), JSON.stringify(session));
+ *       await this.client.set(this.namespace(session.token), JSON.stringify(session), 'EX', DEFAULT_TTL);
  *     } catch (e: any) {
  *       Logger.error(`Could not set cached session: ${e.message}`, loggerCtx);
  *     }