fix: force deployment, support REDIS_URL/REDIS_HOST, and fix vector deserialization
This commit is contained in:
@@ -4,20 +4,32 @@ const globalForRedis = globalThis as unknown as { redis?: Redis };
|
||||
|
||||
const redis =
|
||||
globalForRedis.redis ??
|
||||
new Redis({
|
||||
host: process.env.REDIS_HOST ?? 'localhost',
|
||||
port: parseInt(process.env.REDIS_PORT ?? '6379'),
|
||||
password: process.env.REDIS_PASSWORD,
|
||||
lazyConnect: true,
|
||||
retryStrategy(times) {
|
||||
if (times > 10) {
|
||||
console.error('[redis] Max retries exceeded, will retry in 30s');
|
||||
return 30000;
|
||||
}
|
||||
return Math.min(times * 200, 2000);
|
||||
},
|
||||
maxRetriesPerRequest: 3,
|
||||
});
|
||||
(process.env.REDIS_URL
|
||||
? new Redis(process.env.REDIS_URL, {
|
||||
lazyConnect: true,
|
||||
retryStrategy(times) {
|
||||
if (times > 10) {
|
||||
console.error('[redis] Max retries exceeded, will retry in 30s');
|
||||
return 30000;
|
||||
}
|
||||
return Math.min(times * 200, 2000);
|
||||
},
|
||||
maxRetriesPerRequest: 3,
|
||||
})
|
||||
: new Redis({
|
||||
host: process.env.REDIS_HOST ?? 'localhost',
|
||||
port: parseInt(process.env.REDIS_PORT ?? '6379'),
|
||||
password: process.env.REDIS_PASSWORD,
|
||||
lazyConnect: true,
|
||||
retryStrategy(times) {
|
||||
if (times > 10) {
|
||||
console.error('[redis] Max retries exceeded, will retry in 30s');
|
||||
return 30000;
|
||||
}
|
||||
return Math.min(times * 200, 2000);
|
||||
},
|
||||
maxRetriesPerRequest: 3,
|
||||
}));
|
||||
|
||||
redis.on('error', (err) => {
|
||||
console.error('[redis] Connection error:', err.message);
|
||||
|
||||
Reference in New Issue
Block a user