From 23035e0926713d5c4c51fa4df67cd4e37c408176 Mon Sep 17 00:00:00 2001 From: emmanuel-adah Date: Tue, 16 Jun 2026 05:40:24 +0100 Subject: [PATCH 1/2] refactor: redis service update --- controllers/rateController.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/controllers/rateController.js b/controllers/rateController.js index 627ef95..2f4cea1 100644 --- a/controllers/rateController.js +++ b/controllers/rateController.js @@ -28,9 +28,13 @@ exports.getLatestRates = async (req, res) => { stale: true // Marked as stale because it wasn't in Redis }; - // Re-populate Redis so the next request is fast - await redisClient.set(CACHE_KEY, JSON.stringify(fallbackPayload)); - + try { + // Re-populate Redis so the next request is fast + await redisClient.set(CACHE_KEY, JSON.stringify(fallbackPayload)); + } catch (redisError) { + redisError.message = 'Redis cache update failed. Using stale data.'; + logger.error(redisError.message); + } return res.status(200).json(fallbackPayload); } From 67317215f818ee987bb06b85d1b7b90a55b28d2c Mon Sep 17 00:00:00 2001 From: emmanuel-adah Date: Tue, 16 Jun 2026 05:47:15 +0100 Subject: [PATCH 2/2] refactor: redis service update --- controllers/rateController.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/rateController.js b/controllers/rateController.js index 2f4cea1..d444fe6 100644 --- a/controllers/rateController.js +++ b/controllers/rateController.js @@ -30,7 +30,10 @@ exports.getLatestRates = async (req, res) => { try { // Re-populate Redis so the next request is fast - await redisClient.set(CACHE_KEY, JSON.stringify(fallbackPayload)); + await redisClient.set( + CACHE_KEY, JSON.stringify(fallbackPayload), + { EX: 3600 } + ); } catch (redisError) { redisError.message = 'Redis cache update failed. Using stale data.'; logger.error(redisError.message);