lazy connect to redis
This commit is contained in:
6
src/hooks.server.ts
Normal file
6
src/hooks.server.ts
Normal 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();
|
||||||
|
};
|
||||||
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user