[buddypress-trac] [BuddyPress Trac] #7436: Very slow check_is_friend function

buddypress-trac noreply at wordpress.org
Mon Feb 6 20:34:04 UTC 2017

#7436: Very slow check_is_friend function
 Reporter:  januzi_pl     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  low           |   Milestone:  2.7.5
Component:  Friends       |     Version:  2.7
 Severity:  major         |  Resolution:
 Keywords:  dev-feedback  |
Changes (by r-a-y):

 * keywords:   => dev-feedback
 * version:   => 2.7


 If a site has more than 10,000 users, I'd say it is not a small site :)

 I think `BP_Friends_Friendship::get_friendships()` needs to be refactored.

 Is there a need to fetch all of the user's friendship IDs in one fell
 swoop in `BP_Friends_Friendship::get_friendships()` when we are just doing
 a one-to-one check as is the case in

 Couldn't we cache with the following key - `wp_cache_set(
 "{$initiator_id}:{$friend_id}", 'bp_friends_friendship_pair' )` - when
 there is an initiator and friend ID?

 The hard part is deleting the cache when a user is deleted.  Or we would
 just let that cache get stale since in theory, that cache wouldn't be
 accessed again with the cachekey.

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7436#comment:6>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac

More information about the buddypress-trac mailing list