Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/09/2016 03:30:07 PM (9 years ago)
Author:
boonebgorges
Message:

Cache the results of group ID and count queries.

Query results are cached using an incrementor, and are invalidated in
bulk whenever a group is created, updated, or deleted, or when
groupmeta is modified.

See #5451.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-cache.php

    r10819 r11072  
    253253add_action( 'bp_groups_member_before_delete_invite', 'bp_groups_clear_user_group_cache_on_other_events', 10, 2 );
    254254add_action( 'groups_accept_invite', 'bp_groups_clear_user_group_cache_on_other_events', 10, 2 );
     255
     256/**
     257 * Reset cache incrementor for the Groups component.
     258 *
     259 * This function invalidates all cached results of group queries,
     260 * whenever one of the following events takes place:
     261 *   - A group is created or updated.
     262 *   - A group is deleted.
     263 *   - A group's metadata is modified.
     264 *
     265 * @since 2.7.0
     266 *
     267 * @return bool True on success, false on failure.
     268 */
     269function bp_groups_reset_cache_incrementor() {
     270    return bp_core_reset_incrementor( 'bp_groups' );
     271}
     272add_action( 'groups_group_after_save', 'bp_groups_reset_cache_incrementor' );
     273add_action( 'bp_groups_delete_group',  'bp_groups_reset_cache_incrementor' );
     274add_action( 'updated_group_meta',      'bp_groups_reset_cache_incrementor' );
     275add_action( 'deleted_group_meta',      'bp_groups_reset_cache_incrementor' );
     276add_action( 'added_group_meta',        'bp_groups_reset_cache_incrementor' );
    255277
    256278/* List actions to clear super cached pages on, if super cache is installed */
Note: See TracChangeset for help on using the changeset viewer.