From c96d24eafed4ef06add6ff2587bd30692d8bb1fa Mon Sep 17 00:00:00 2001 From: Tanya Byrne Date: Mon, 24 Aug 2020 13:53:23 +0100 Subject: [PATCH] Convert those strings --- api/src/middleware/cache.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/src/middleware/cache.ts b/api/src/middleware/cache.ts index bce61095fb..3964027928 100644 --- a/api/src/middleware/cache.ts +++ b/api/src/middleware/cache.ts @@ -28,6 +28,9 @@ const cacheMiddleware: RequestHandler = asyncHandler(async (req, res, next) => { const TTL = req.query.TTL; const checkDeath = req.query.dTTL; + const TTLnum = Number(TTL); + const cDnum = Number(checkDeath); + // we have two options here. Redis or node cache if (env.CACHE_TYPE === 'redis') { if (!redisClient) { @@ -44,13 +47,13 @@ const cacheMiddleware: RequestHandler = asyncHandler(async (req, res, next) => { } if (!resultData) { // set data and then return - redisClient.setex(key, TTL, JSON.stringify(res.json)); + redisClient.setex(key, TTLnum, JSON.stringify(res.json)); } }); } else { // use the node cache // set for ten minutes - const nodeCache = new CacheService(TTL, checkDeath); + const nodeCache = new CacheService(TTLnum, cDnum); nodeCache.getCache(key, JSON.stringify(res.json)); }