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

buddypress-trac noreply at wordpress.org
Thu Feb 22 19:41:05 UTC 2018

#7436: Very slow check_is_friend function
 Reporter:  januzi_pl     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  high          |   Milestone:  Awaiting Contributions
Component:  Friends       |     Version:  2.7
 Severity:  major         |  Resolution:
 Keywords:  dev-feedback  |

Comment (by dcavins):

 Hi all-

 I've added a new patch that changes
 `BP_Friends_Friendship::check_is_friend()` so that it does not loop
 through the big friends list each time. I've added a customized bulk cache
 warmer that acts like a `_get_non_cached_ids()` for a list of maybe-friend
 users, and caches individual friendships as Boone and Ray has discussed
 using our incremented cache helpers and the two users as the cache key,
 like `'initiator_user_id:friend_user_id'`.

 I've also added a new general cache function,
 `bp_core_delete_incremented_cache()` to remove these cached items by key
 when a friendship is updated.

 Finally, this change doesn't replace the user-specific friendship cache as
 introduced in 2.5. I think there's still value to having that cached,
 since it is used in friendship calls that refer to all friendships for a
 user. The problem was that hoisting that load for 20 `check_is_friend()`
 calls was too unwieldy. There seem to me to be two different things going
 on: friendships from the perspective of a particular user, and the simple
 check, "Are these two users friends?"

 Thanks for your comments,


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

More information about the buddypress-trac mailing list