()
| 85 | let redis: Redis | null = null |
| 86 | |
| 87 | function getRedis(): Redis { |
| 88 | if (!redis) { |
| 89 | redis = new Redis(REDIS_URL, { |
| 90 | maxRetriesPerRequest: 3, |
| 91 | lazyConnect: true, |
| 92 | }) |
| 93 | redis.on('error', (err) => { |
| 94 | console.error('[collab] Redis error:', err.message) |
| 95 | }) |
| 96 | redis.connect().catch((err) => { |
| 97 | console.error('[collab] Redis connection failed:', err) |
| 98 | }) |
| 99 | } |
| 100 | return redis |
| 101 | } |
| 102 | |
| 103 | function redisYdocKey(boardUuid: string): string { |
| 104 | return `collab:ydoc:${boardUuid}` |