-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: breadcrumb cache issue #2215
Changes from all commits
6cd266b
babf1c3
77782f0
c46818e
bd0d213
e7906ee
94634b4
d7dd3f3
ce69a7a
6f90d44
7ff38b7
dfffad0
a90dbc0
b35831f
789b2e5
6e09502
8078b80
4379c23
a74c234
9b0c4fc
8764aab
8f281d7
18ef32b
c4def6c
4f903fe
2aa9344
9893080
a4b52e4
3d88ed0
72799ee
7250c94
42d1b4d
cfde7e7
34eabed
c77e427
f1c6570
e20ffd1
0fa0856
dff9152
8282538
6a05ff2
7c51d96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,12 @@ | ||||||||||||||||||||||||||||||||||||||||
"use server"; | ||||||||||||||||||||||||||||||||||||||||
import { revalidatePath } from "next/cache"; | ||||||||||||||||||||||||||||||||||||||||
import { revalidatePath, revalidateTag } from "next/cache"; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
export async function revalidate(path: string) { | ||||||||||||||||||||||||||||||||||||||||
revalidatePath(path, "page"); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
export async function revalidateMyTag(slug: string) { | ||||||||||||||||||||||||||||||||||||||||
revalidateTag(slug); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling and improve function documentation The function should include error handling and proper documentation to improve maintainability and reliability. Consider applying these improvements: -export async function revalidateMyTag(slug: string) {
- revalidateTag(slug);
-}
+/**
+ * Revalidates cache for a specific tag
+ * @param slug - The cache tag to revalidate
+ * @throws {Error} If the slug is invalid or revalidation fails
+ */
+export async function revalidateMyTag(slug: string) {
+ if (!slug || typeof slug !== 'string') {
+ throw new Error('Invalid cache tag provided');
+ }
+ try {
+ await revalidateTag(slug);
+ } catch (error) {
+ console.error('Failed to revalidate cache tag:', error);
+ throw error;
+ }
+} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
export { revalidateMyTag as revalidateTag }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const tags = { | ||
api: (apiId: string): string => `api-${apiId}`, | ||
permission: (permissionId: string): string => `permission-${permissionId}`, | ||
namespace: (namespaceId: string): string => `namespace-${namespaceId}`, | ||
role: (roleId: string): string => `role-${roleId}`, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider implementing type-safe cache keys and tags.
Based on the PR discussion about type safety, consider implementing a type-safe wrapper for cache keys and tags to prevent typos and improve maintainability.
Example implementation: