Explorar el Código

fix(homepage): add logging for cache hits and misses in getCategoryTags method

Dave hace 1 mes
padre
commit
e9bd97f599
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4 2
      apps/box-app-api/src/feature/homepage/homepage.service.ts

+ 4 - 2
apps/box-app-api/src/feature/homepage/homepage.service.ts

@@ -311,14 +311,16 @@ export class HomepageService {
 
   async getCategoryTags(channelId: string): Promise<any[]> {
     try {
+      this.logger.log(`Cache miss for category tags of channelId=${channelId}`);
       const cacheKey = `category:tag:${channelId}`;
       const cache = await this.redis.getJson<HomeCategoryCacheItem[]>(cacheKey);
       if (cache) {
+        this.logger.log(
+          `Cache hit for category tags of channelId=${channelId}`,
+        );
         return cache;
       }
 
-      this.logger.log(`Cache miss for category tags of channelId=${channelId}`);
-
       const channel = await this.prisma.channel.findUnique({
         where: { channelId },
         // select: {