From c7fdfd1df26ded5167d0d1b0342664bb5520cdc9 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Wed, 20 Sep 2023 22:02:40 -0500 Subject: [PATCH] Tweak cache tag handling --- src/cache/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cache/index.ts b/src/cache/index.ts index 39da6d0d..0ac85e74 100644 --- a/src/cache/index.ts +++ b/src/cache/index.ts @@ -14,7 +14,7 @@ const TAG_PHOTOS_COUNT = 'photos-count'; const TAG_TAGS = 'tags'; const getPhotosCacheTags = (options: GetPhotosOptions = {}) => { - const tags = [TAG_PHOTOS]; + const tags = []; const { sortBy, @@ -37,7 +37,7 @@ const getPhotosCacheTags = (options: GetPhotosOptions = {}) => { return tags; }; -const tagForPhoto = (photoId: string) => `photo-${photoId}`; +const getPhotoCacheTag = (photoId: string) => `photo-${photoId}`; export const revalidatePhotosTag = () => revalidateTag(TAG_PHOTOS); @@ -45,8 +45,8 @@ export const revalidatePhotosTag = () => export const getPhotosCached: typeof getPhotos = (...args) => unstable_cache( () => getPhotos(...args), - getPhotosCacheTags(...args), { - tags: getPhotosCacheTags(...args), + [TAG_PHOTOS, ...getPhotosCacheTags(...args)], { + tags: [TAG_PHOTOS, ...getPhotosCacheTags(...args)], } )().then(parseCachedPhotosDates); @@ -61,8 +61,8 @@ export const getPhotosCountCached: typeof getPhotosCount = (...args) => export const getPhotoCached: typeof getPhoto = (...args) => unstable_cache( () => getPhoto(...args), - [TAG_PHOTOS, tagForPhoto(...args)], { - tags: [TAG_PHOTOS, tagForPhoto(...args)], + [TAG_PHOTOS, getPhotoCacheTag(...args)], { + tags: [TAG_PHOTOS, getPhotoCacheTag(...args)], } )().then(photo => photo ? parseCachedPhotoDates(photo) : undefined);