API, Backend & Frontend
This commit is contained in:
25
backend/redis-client.js
Normal file
25
backend/redis-client.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createClient } from 'redis';
|
||||
|
||||
// Create Redis client
|
||||
const redisClient = createClient({
|
||||
socket: {
|
||||
host: process.env.REDIS_HOST || 'localhost',
|
||||
port: process.env.REDIS_PORT || 6379
|
||||
},
|
||||
password: process.env.REDIS_PASSWORD || undefined
|
||||
});
|
||||
|
||||
// Error handler
|
||||
redisClient.on('error', (err) => {
|
||||
console.error('Redis Client Error:', err);
|
||||
});
|
||||
|
||||
// Connection handler
|
||||
redisClient.on('connect', () => {
|
||||
console.log('✅ Connected to Redis');
|
||||
});
|
||||
|
||||
// Connect to Redis
|
||||
await redisClient.connect();
|
||||
|
||||
export default redisClient;
|
||||
Reference in New Issue
Block a user