import { createClient } from 'redis';

const REDIS_URL = process.env.REDIS_URL || 'redis://localhost:6379';

export async function createRedisClient() {
  try {
    const client = createClient({
      url: REDIS_URL
    });

    await client.connect();
    console.log('Connected to Redis');
    
    client.on('error', (err) => {
      console.error('Redis error:', err);
    });

    return client;
  } catch (error) {
    console.error('Redis connection error:', error);
    throw error;
  }
} 