Improve app speed and responsiveness for users around the world
Improves Redis connection handling and introduces a new hook `usePerformanceOptimization.ts` for font preloading and RTL layout optimization. Replit-Commit-Author: Agent Replit-Commit-Session-Id: c5f0c281-8dd8-4846-b452-4a07bcd21062 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9777c70b-fc38-4831-8d6b-78dfffe041b0/e30af87a-6b1f-4210-9add-1f060bd1d9e3.jpg
This commit is contained in:
@@ -16,19 +16,27 @@ class CacheService {
|
||||
|
||||
private async initializeRedis() {
|
||||
try {
|
||||
// Try to connect to Redis if available
|
||||
const redisUrl = process.env.REDIS_URL || 'redis://localhost:6379';
|
||||
const redisUrl = process.env.REDIS_URL;
|
||||
if (!redisUrl) {
|
||||
this.redis = null;
|
||||
this.isRedisConnected = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.redis = new Redis(redisUrl, {
|
||||
retryDelayOnFailover: 100,
|
||||
maxRetriesPerRequest: 3,
|
||||
lazyConnect: true
|
||||
maxRetriesPerRequest: 0,
|
||||
lazyConnect: true,
|
||||
enableOfflineQueue: false,
|
||||
connectTimeout: 2000
|
||||
});
|
||||
|
||||
this.redis.on('error', () => {
|
||||
this.isRedisConnected = false;
|
||||
});
|
||||
|
||||
await this.redis.ping();
|
||||
this.isRedisConnected = true;
|
||||
console.log('Redis cache connected');
|
||||
} catch (error) {
|
||||
console.log('Redis not available, using memory cache');
|
||||
this.redis = null;
|
||||
this.isRedisConnected = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user