Skip to content

Commit 53e05a0

Browse files
authored
feat(redis-string): remove cache when key not presented in mapping table (#5)
1 parent 6037700 commit 53e05a0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/nextjs-cache-handler/src/handlers/redis-strings.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,21 @@ export default function createHandler({
200200
return null;
201201
}
202202

203+
const sharedTagKeyExists = await client.hExists(
204+
getTimeoutRedisCommandOptions(timeoutMs),
205+
keyPrefix + sharedTagsKey,
206+
key,
207+
);
208+
209+
if (!sharedTagKeyExists) {
210+
await client.unlink(
211+
getTimeoutRedisCommandOptions(timeoutMs),
212+
keyPrefix + key,
213+
);
214+
215+
return null;
216+
}
217+
203218
const combinedTags = new Set([...cacheValue.tags, ...implicitTags]);
204219

205220
if (combinedTags.size === 0) {

0 commit comments

Comments
 (0)