Skip to content

Commit

Permalink
comment update
Browse files Browse the repository at this point in the history
  • Loading branch information
wizardlyhel committed Oct 23, 2024
1 parent daa1fac commit 3d6e9b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .changeset/serious-pillows-hug.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default {
+ return withCache.run({
+ cacheKey: ['my-cms', query],
+ cacheStrategy: CacheLong(),
+ shouldCacheResult: (body) => !body?.errors,
+ // Cache if there are no data errors or a specific data that make this result not suited for caching
+ shouldCacheResult: (result) => !result?.errors,
+ }, async(params) => {
const response = await fetch('my-cms.com/api', {
method: 'POST',
Expand Down Expand Up @@ -60,7 +61,8 @@ export default {
},
{
cacheStrategy: options.cache ?? CacheLong(),
shouldCacheResponse: (body) => !body?.error,
// Cache if there are no data errors or a specific data that make this result not suited for caching
shouldCacheResponse: (result) => !result?.error,
cacheKey: ['my-cms', body],
displayName: 'My CMS query',
},
Expand Down
4 changes: 2 additions & 2 deletions packages/hydrogen/src/cache/create-with-cache.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
// Optionally, specify a cache strategy.
// Default is CacheShort().
cacheStrategy: CacheLong(),
// Cache if there are no GralhQL errors or a specific result that make this result not suited for caching:
// Cache if there are no data errors or a specific data that make this result not suited for caching
shouldCacheResponse: (result) => !(result?.errors || result?.isLoggedIn),
// Optionally, add extra information to show
// in the Subrequest Profiler utility.
Expand All @@ -49,7 +49,7 @@ export default {
// Optionally, specify a cache strategy.
// Default is CacheShort().
cacheStrategy: CacheLong(),
// Cache if there are no GralhQL errors or a specific result that make this result not suited for caching:
// Cache if there are no data errors or a specific data that make this result not suited for caching
shouldCacheResponse: (result) => !(result?.errors || result?.isLoggedIn),
}, async (params) => {
// Run multiple subrequests in parallel, or any other async operations.
Expand Down
4 changes: 2 additions & 2 deletions packages/hydrogen/src/cache/create-with-cache.example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
// Optionally, specify a cache strategy.
// Default is CacheShort().
cacheStrategy: CacheLong(),
// Cache if there are no GralhQL errors or a specific result that make this result not suited for caching:
// Cache if there are no data errors or a specific data that make this result not suited for caching
shouldCacheResponse: (result) => !(result?.errors || result?.isLoggedIn),
// Optionally, add extra information to show
// in the Subrequest Profiler utility.
Expand All @@ -67,7 +67,7 @@ export default {
// Optionally, specify a cache strategy.
// Default is CacheShort().
cacheStrategy: CacheLong(),
// Cache if there are no GralhQL errors or a specific result that make this result not suited for caching:
// Cache if there are no data errors or a specific data that make this result not suited for caching
shouldCacheResult: (result: MergedResponse) => !(result?.errors || result?.isLoggedIn),
}, async (params) => {
// Run multiple subrequests in parallel, or any other async operations.
Expand Down

0 comments on commit 3d6e9b8

Please sign in to comment.