Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

#5414 closed enhancement (fixed)

Object cache all item counts associated with the adminbar

Reported by: r-a-y's profile r-a-y 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)

5414.group_invite_count.01.patch (4.5 KB) - added by r-a-y 11 years ago.

Download all attachments as: .zip

Change History (8)

#1 @r-a-y
11 years ago

In 8053:

Cache the unread inbox count for a user.

This commit:

  • Caches calls to BP_Messages_Thread::get_inbox_count()
  • Invalidates the cache when a new message is sent or deleted
  • Adds a unit test

See #5414

#2 @r-a-y
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 @boonebgorges
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.)

#4 @r-a-y
11 years ago

In 8105:

Cache the friendship request user IDs for a given user.

This commit:

  • Caches calls to BP_Friends_Friendship::get_friendship_request_user_ids()
  • Invalidates the friend request cache when a friendship is saved or removed
  • Adds unit tests

See #5435, #5414

#5 @r-a-y
11 years ago

In 8200:

Cache the group invite count for a user.

This commit:

  • Caches calls to BP_Groups_Member::get_invite_count_for_user()
  • Invalidates the group invite count cache on various actions
  • Adds a unit test

See #5414

#6 @r-a-y
11 years ago

Closing this to clear the 2.0 milestone.

#7 @r-a-y
11 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.