this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: account for empty tag list in tag cache (#918)

authored by

Victor Berchet and committed by
GitHub
eeb18bb7 5d0042bd

+18 -6
+5
.changeset/great-eyes-tan.md
··· 1 + --- 2 + "@opennextjs/cloudflare": patch 3 + --- 4 + 5 + refactor: account for empty tag list in tag cache
+6 -2
packages/cloudflare/src/api/overrides/tag-cache/d1-next-tag-cache.ts
··· 14 14 15 15 async getLastRevalidated(tags: string[]): Promise<number> { 16 16 const { isDisabled, db } = this.getConfig(); 17 - if (isDisabled) return 0; 17 + if (isDisabled || tags.length === 0) { 18 + return 0; 19 + } 18 20 try { 19 21 const result = await db 20 22 .prepare( ··· 36 38 37 39 async hasBeenRevalidated(tags: string[], lastModified?: number): Promise<boolean> { 38 40 const { isDisabled, db } = this.getConfig(); 39 - if (isDisabled) return false; 41 + if (isDisabled || tags.length === 0) { 42 + return false; 43 + } 40 44 try { 41 45 const result = await db 42 46 .prepare(
+6 -3
packages/cloudflare/src/api/overrides/tag-cache/do-sharded-tag-cache.ts
··· 130 130 131 131 public async getLastRevalidated(tags: string[]): Promise<number> { 132 132 const { isDisabled } = this.getConfig(); 133 - if (isDisabled) return 0; 134 - if (tags.length === 0) return 0; // No tags to check 133 + if (isDisabled || tags.length === 0) { 134 + return 0; 135 + } 135 136 const deduplicatedTags = Array.from(new Set(tags)); // We deduplicate the tags to avoid unnecessary requests 136 137 try { 137 138 const shardedTagGroups = this.groupTagsByDO({ tags: deduplicatedTags }); ··· 177 178 */ 178 179 public async hasBeenRevalidated(tags: string[], lastModified?: number): Promise<boolean> { 179 180 const { isDisabled } = this.getConfig(); 180 - if (isDisabled) return false; 181 + if (isDisabled || tags.length === 0) { 182 + return false; 183 + } 181 184 try { 182 185 const shardedTagGroups = this.groupTagsByDO({ tags }); 183 186 const shardedTagRevalidationOutcomes = await Promise.all(
+1 -1
packages/cloudflare/src/api/overrides/tag-cache/kv-next-tag-cache.ts
··· 26 26 27 27 async getLastRevalidated(tags: string[]): Promise<number> { 28 28 const kv = this.getKv(); 29 - if (!kv) { 29 + if (!kv || tags.length === 0) { 30 30 return 0; 31 31 } 32 32