Skip to content

Commit d6c69c5

Browse files
committed
Wrapper redis cache i try catch
1 parent 8751dea commit d6c69c5

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

packages/server/src/cache/page-cache-handler.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,20 @@ export default class PageCacheHandler {
2525
return fromLocalCache;
2626
}
2727

28-
const fromRedisCache = await redisCache.getRender(key);
29-
logger.info(
30-
`PageCache: content ${key} in fromRedisCache: ${fromRedisCache ? 'found' : 'not found'}: ${JSON.stringify(fromRedisCache)}`
31-
);
32-
if (!fromRedisCache) {
28+
try {
29+
const fromRedisCache = await redisCache.getRender(key);
30+
logger.info(
31+
`PageCache: content ${key} in fromRedisCache: ${fromRedisCache ? 'found' : 'not found'}: ${JSON.stringify(fromRedisCache)}`
32+
);
33+
if (!fromRedisCache) {
34+
return null;
35+
}
36+
37+
return fromRedisCache;
38+
} catch (error) {
39+
logger.error(`PageCache: error getting fromRedisCache: ${error}`);
3340
return null;
3441
}
35-
36-
return fromRedisCache;
3742
}
3843

3944
public async set(...args: Parameters<FileSystemCache['set']>) {

packages/shared/src/redis_local.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ class RedisCacheImpl {
8686
.getEx(fullKey, {
8787
PX: this.renderCacheTTL,
8888
})
89-
.then((result) => (result ? JSON.parse(result) : result))
89+
.then((result) => {
90+
logger.info(
91+
`RedisCache: getRender parsing result: ${result ? JSON.parse(result) : result}`
92+
);
93+
return result ? JSON.parse(result) : result;
94+
})
9095
.catch((e) => {
9196
logger.error(`Error getting render cache value for key ${fullKey} - ${e}`);
9297
return Promise.resolve(null);

0 commit comments

Comments
 (0)