Skip to content

Commit

Permalink
Adopt a convention for the cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos committed Apr 5, 2021
1 parent 205bd12 commit 996a27d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/hooks/useContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('useContent', () => {

expect(useCroct).toBeCalled();
expect(useSuspense).toBeCalledWith({
cacheKey: 'slot:unique:home-banner',
cacheKey: 'useContent:unique:home-banner',
initial: {
title: 'loading',
},
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function useContent<P extends NullableJsonObject, I extends SlotId = Slot
const croct = useCroct();

return useSuspense({
cacheKey: `content:${cacheKey ?? ''}:${slotId}`,
cacheKey: `useContent:${cacheKey ?? ''}:${slotId}`,
loader: () => croct.fetch<P>(slotId).then(({payload}) => payload),
fallback: fallback,
initial: initial,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useEvaluation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('useEvaluation', () => {

expect(useCroct).toBeCalled();
expect(useSuspense).toBeCalledWith({
cacheKey: 'evaluation:unique:location:{"foo":"bar"}',
cacheKey: 'useEvaluation:unique:location:{"foo":"bar"}',
initial: 'loading',
fallback: 'error',
expiration: 50,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useEvaluation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useEvaluation<T extends JsonValue>(expression: string, options:
const croct = useCroct();

return useSuspense({
cacheKey: `evaluation:${cacheKey ?? ''}:${expression}:${JSON.stringify(options.attributes ?? '')}`,
cacheKey: `useEvaluation:${cacheKey ?? ''}:${expression}:${JSON.stringify(options.attributes ?? '')}`,
loader: () => croct.evaluate<T>(expression, evaluationOptions),
fallback: fallback,
initial: initial,
Expand Down

0 comments on commit 996a27d

Please sign in to comment.