lazy connect to redis

This commit is contained in:
Fran Jurmanović
2025-02-10 22:38:19 +01:00
parent 174e1c89ae
commit e9487ba38f
2 changed files with 7 additions and 1 deletions

6
src/hooks.server.ts Normal file
View File

@@ -0,0 +1,6 @@
import type { ServerInit } from '@sveltejs/kit';
import { redisSessionManager } from '$stores/redisSessionManager';
export const init: ServerInit = async () => {
await redisSessionManager['redisClient'].connect();
};

View File

@@ -4,7 +4,7 @@ import { env } from '$env/dynamic/private';
// Now we will create new Instance for RedisSessionStore // Now we will create new Instance for RedisSessionStore
const options = { const options = {
redisClient: new Redis(env.REDIS_URL), redisClient: new Redis(env.REDIS_URL, { lazyConnect: true }),
secret: env.SECRET secret: env.SECRET
}; };
// These are the required options to use RedisSessionStore. // These are the required options to use RedisSessionStore.