Skip to content

Commit

Permalink
feat(cache): cosmetic cache validation logic
Browse files Browse the repository at this point in the history
The cache validation logic in `getCache` function has been updated.
Previously, it returned the cache data if it ended with `hashComment`.
Now, it returns null if the data does not end with `hashComment`,
indicating that it's not a valid cache. This change improves the
accuracy of cache validation.
  • Loading branch information
ryoppippi committed Jun 16, 2024
1 parent 34f3ccc commit 0e8b5a3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/unplugin-typia/src/core/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ export async function getCache(

const hashComment = await getHashComment(key);

if (data.endsWith(hashComment)) {
return wrap<Data>(data);
/* if data does not end with hashComment, the cache is invalid */
if (!data.endsWith(hashComment)) {
return null;
}

return null;
return wrap<Data>(data);
}

/**
Expand Down

0 comments on commit 0e8b5a3

Please sign in to comment.