From 2394a137b010ff8fded979e8fd5a3c00bba3b533 Mon Sep 17 00:00:00 2001 From: Henrik Nygren Date: Thu, 12 Oct 2023 16:00:27 +0300 Subject: [PATCH] Log when using graphql response cache --- backend/middlewares/cache.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/middlewares/cache.ts b/backend/middlewares/cache.ts index f9ccb5f29..8d9a64f0d 100644 --- a/backend/middlewares/cache.ts +++ b/backend/middlewares/cache.ts @@ -29,8 +29,14 @@ export const cachePlugin = () => const hash = createHash("sha512").update(key).digest("hex") + let usedGraphqlCache = true + const res = await redisify( - async () => next(root, args, context, info), + async () => { + usedGraphqlCache = false + context.logger.info(`Not using graphql response cache for ${key}`) + return next(root, args, context, info) + }, { prefix: "graphql-response", expireTime: 300, @@ -40,6 +46,9 @@ export const cachePlugin = () => logger: context.logger, }, ) + if (usedGraphqlCache) { + context.logger.info(`Used graphql response cache for ${key}`) + } return res } },