Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/01/2015 11:14:16 PM (11 years ago)
Author:
johnjamesjacoby
Message:

XProfile: Introduce bp_xprofile_groups cache group, to replace bp cache group usage.

  • Reduces field group cache keys down to just their ID, using a unique cache group
  • Use all key instead of 'xprofile_groups_inc_empty`
  • Use default_visibility_levels key instead of xprofile_default_visibility_levels

See #6341, #5733.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-group.php

    r9671 r9676  
    8282                global $wpdb;
    8383
    84                 $group = wp_cache_get( 'xprofile_group_' . $this->id, 'bp' );
     84                $group = wp_cache_get( $id, 'bp_xprofile_groups' );
    8585
    8686                if ( false === $group ) {
    87                         $bp = buddypress();
     87                        $bp    = buddypress();
    8888                        $group = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id ) );
     89                        wp_cache_set( $id, $group, 'bp_xprofile_groups' );
    8990                }
    9091
     
    9495
    9596                $this->id          = $group->id;
    96                 $this->name        = stripslashes( $group->name );
    97                 $this->description = stripslashes( $group->description );
     97                $this->name        = $group->name;
     98                $this->description = $group->description;
    9899                $this->can_delete  = $group->can_delete;
    99100                $this->group_order = $group->group_order;
     
    456457
    457458                        // If cached data is found, use it
    458                         $cache_key  = 'xprofile_group_' . $group_id;
    459                         $group_data = wp_cache_get( $cache_key, 'bp' );
     459                        $group_data = wp_cache_get( $group_id, 'bp_xprofile_groups' );
    460460                        if ( false !== $group_data ) {
    461461                                $groups[ $group_id ] = $group_data;
     
    493493
    494494                                        // Cache previously uncached group data
    495                                         $cache_key = 'xprofile_group_' . $gdata->id;
    496                                         wp_cache_set( $cache_key, $gdata, 'bp' );
     495                                        wp_cache_set( $gdata->id, $gdata, 'bp_xprofile_groups' );
    497496                                }
    498497                        }
     
    543542
    544543                // Purge profile field group cache
    545                 wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );
     544                wp_cache_delete( 'all', 'bp_xprofile_groups' );
    546545
    547546                $bp = buddypress();
     
    608607                global $wpdb;
    609608
    610                 $default_visibility_levels = wp_cache_get( 'xprofile_default_visibility_levels', 'bp' );
     609                $default_visibility_levels = wp_cache_get( 'default_visibility_levels', 'bp_xprofile' );
    611610
    612611                if ( false === $default_visibility_levels ) {
     
    628627                        }
    629628
    630                         wp_cache_set( 'xprofile_default_visibility_levels', $default_visibility_levels, 'bp' );
     629                        wp_cache_set( 'default_visibility_levels', $default_visibility_levels, 'bp_xprofile' );
    631630                }
    632631
Note: See TracChangeset for help on using the changeset viewer.