Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/08/2011 02:57:38 AM (13 years ago)
Author:
boonebgorges
Message:

Introduces automatic meta cache features.
Introduces bp_update_meta_cache(), for collecting all metadata associated with an object or with multiple objects in one fell swoop, and adding it to the WP cache for quicker access later
Introduces bp_groups_update_meta_cache(), for collecting groupmeta at the beginning of a group loop
Modifies the BP_Groups_Group object so that groupmeta is fetched in the populate() and get() methods
Fixes #3799

File:
1 edited

Legend:

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

    r4961 r5460  
    1212// Exit if accessed directly
    1313if ( !defined( 'ABSPATH' ) ) exit;
     14
     15/**
     16 * Slurps up groupmeta
     17 *
     18 * This function is called in two places in the BP_Groups_Group class:
     19 *   - in the populate() method, when single group objects are populated
     20 *   - in the get() method, when multiple groups are queried
     21 *
     22 * It grabs all groupmeta associated with all of the groups passed in $group_ids and adds it to
     23 * the WP cache. This improves efficiency when using groupmeta inline
     24 *
     25 * @param int|str|array $group_ids Accepts a single group_id, or a comma-separated list or array of
     26 *    group ids
     27 */
     28function bp_groups_update_meta_cache( $group_ids = false ) {
     29    global $bp;
     30   
     31    $cache_args = array(
     32        'object_ids'       => $group_ids,
     33        'object_type'      => $bp->groups->id,
     34        'object_column'    => 'group_id',
     35        'meta_table'       => $bp->groups->table_name_groupmeta,
     36        'cache_key_prefix' => 'bp_groups_groupmeta'
     37    );
     38   
     39    bp_update_meta_cache( $cache_args );
     40}
    1441
    1542function groups_clear_group_object_cache( $group_id ) {
Note: See TracChangeset for help on using the changeset viewer.