import{logger as e}from"../../logger/index.mjs";import t from"ioredis";let n=null;const r=async()=>{try{if(n)return n;let r=process.env.REDIS_URL;if(!r){let t=`REDIS_URL is not defined`;throw e.error(t),Error(t)}let i=new t(r,{maxRetriesPerRequest:null,lazyConnect:!0});return i.on(`error`,t=>{e.error(`Redis connection error:`,t)}),await i.connect(),e.info(`Redis connected`),n=i,n}catch(t){let n=`Redis connection error - ${t.message}`;throw e.error(n),Error(n)}},i=()=>{if(!n)throw Error(`Redis not connected. Call connectRedis() first.`);return n};export{r as connectRedis,i as getRedisClient};
//# sourceMappingURL=connectRedis.mjs.map