[buddypress-trac] [BuddyPress Trac] #5350: Caching for the activity component

buddypress-trac noreply at wordpress.org
Tue Jan 21 22:07:04 UTC 2014

#5350: Caching for the activity component
 Reporter:  boonebgorges  |      Owner:
     Type:  task          |     Status:  new
 Priority:  normal        |  Milestone:  Future Release
Component:  Activity      |    Version:
 Severity:  normal        |   Keywords:
 We currently do (almost) no caching in the activity component. We should.

 There are two kinds of entities that would benefit from caching throughout
 bp-activity: *items* and *queries*.

 Activity items will be fairly straightforward to cache. I suggest the
 following lines of attack:
 - In `BP_Activity_Activity::get()`, after we've pulled up data associated
 with individual activity items matching the query, put it in item-specific
 cache slots.
 - Assuming we split our activity query as suggested in #5349, we can then
 use the activity item cache when we fill in the missing data about each
 activity item. See https://core.trac.wordpress.org/browser/tags/3.8/src
 /wp-includes/query.php#L2927 for a similar tactic in `WP_Query`.
 - Cache busting as appropriate.

 *Query* caching will be a good deal more complex, and will probably be
 best saved for after item caching is in place. The problem is
 invalidation. A single activity item (say, "Boone posted an update in the
 group Foo") is associated with multiple BP (Boone, Foo) and multiple
 activity query types (sitewide stream, Boone's stream, Foo's stream, My
 Groups for anyone who is a member of Foo, My Friends for any of Boone's
 friends, etc). I've been working for a while on a more formal proposal for
 working around this problem, but the short version is: we store (in cache)
 an index of cache keys, where a given query cache key will be listed with
 multiple associated items (eg, the cache key associated with the "Boone's
 20 most recent My Groups activity" query will be indexed with Boone as
 well as each of Boone's groups; then, when *any* of those items gets new
 activity, all associated cache keys are flushed. I'll work on something a
 little clearer than that, but consider this an initial idea-float.

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5350>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac

More information about the buddypress-trac mailing list