Opened 11 years ago
Closed 11 years ago
#5414 closed enhancement (fixed)
Object cache all item counts associated with the adminbar
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Core | Keywords: | has-patch |
Cc: |
Description
When a user is logged in, there are a bunch of queries associated with getting the item count so it is displayed in the WP Adminbar.
We can get rid of most (if not, all) of these queries with object caching.
This ticket will be a general catch-all for all changesets related to this.
Attachments (1)
Change History (8)
#2
@
11 years ago
- Keywords has-patch added
group_invite_count.01.patch
adds object caching to the group invite count for a user.
What I need feedback on is the cache callback functions. As outlined in the patch, I had to create three functions in bp-groups-cache.php to clear the cache because the parameters in our API hooks are inconsistent.
What I'd rather do is hardcode the wp_cache_delete()
calls directly where they are needed instead of using the hooked functions, but this isn't how we've done things in the past.
#3
@
11 years ago
Generally I would say to hardcode it with the justification "let's not make it any more complicated than it has to be". But in the case of cache invalidation, I do think it's helpful to have the items centrally located. When the time comes to debug problems with it (and the time will come!), it'll be easier to have it in a single place. So, where possible, let's go with the add_action()
technique.
That said, if you feel really strongly about it, go ahead and hardcode it. My preference here is very very slight. I'll just be sure to call you first when the bug reports roll in and it's time to write unit tests :)
One suggestion (and this is something that could use improvement throughout). The callbacks end up effectively being wrappers for the wp_cache_delete()
call. If we're going to have the wrapper in virtue of using the callback technique, we may as well use that wrapper elsewhere. So, keep bp_groups_clear_invite_count_for_user()
as is, and then use it in the other two functions. (This'll make it easier if we want to make cache groups dynamic at some point in the future.)
In 8053: