Profiles: Cache user badge lookups#684
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR introduces object-caching for Profile badge lookups (get_user_badges()) and ensures that cached badge data is invalidated when badge group membership changes via the Profiles association handler, reducing repeated DB queries for frequently-accessed badge data.
Changes:
- Cache
get_user_badges()results in theuser_metaobject-cache group under a per-user, namespaced key. - Invalidate the per-user badge cache when users are added to / removed from badge groups via the association handler.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| wordpress.org/public_html/wp-content/mu-plugins/pub/profile-helpers.php | Adds per-user caching for get_user_badges() lookups using a namespaced cache key. |
| profiles.wordpress.org/public_html/wp-content/plugins/wporg-profiles-association-handler/wporg-profiles-association-handler.php | Clears the per-user badge cache when badge group membership is modified through association requests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0c8277e to
d9a902b
Compare
Caches get_user_badges() in the user_meta cache group for one hour and clears the per-user badge cache when badge group membership changes. See https://meta.trac.wordpress.org/ticket/2214.
d9a902b to
075135f
Compare
Splits the badge lookup cache change out of #677 so the support badge PR can stay focused.\n\nThis caches get_user_badges() in the existing user_meta cache group with a namespaced per-user key, and clears that cached badge list when badge group membership changes through the Profiles association handler.\n\nSee https://meta.trac.wordpress.org/ticket/2214.