import IORedis from 'ioredis';
import { logger } from './logger.server';

export const connection = new IORedis(process.env.REDIS_URL!, {
  maxRetriesPerRequest: null, // Important for BullMQ
  password: process.env.REDIS_PASSWORD,
});

// --- Redis Connection Event Listeners ---
connection.on('connect', () => {
  logger.info('[Redis] Connection established successfully.');
});

connection.on('error', (err) => {
  logger.error({ err }, '[Redis] Connection error.');
});