(roomName)
| 49 | // Query Redis for messages for a specific room |
| 50 | // If not in Redis, query the database |
| 51 | async function getRoomFromCache(roomName) { |
| 52 | if (!(await redisClient.exists(roomName))) { |
| 53 | const room = getRoomFromDatabase(roomName); |
| 54 | if (room) { |
| 55 | await redisClient.set(roomName, JSON.stringify(room)); |
| 56 | } |
| 57 | } |
| 58 | return JSON.parse(await redisClient.get(roomName)); |
| 59 | } |
| 60 | |
| 61 | // In-memory database example - |
| 62 | // Production applications should use a persistent database such as Firestore |
no test coverage detected