Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/09/2015 08:38:37 PM (10 years ago)
Author:
johnjamesjacoby
Message:

XProfile data cache group updates:

  • Switches from dynamic cache group to unique key for $user_id:$field_id.
  • Introduces bp_xprofile_get_non_cached_field_ids() as a helper, based on bp_get_non_cached_field_ids().
  • Registers bp_xprofile and bp_xprofile_data as global cache groups.
  • Updates unit tests to pass with new cache keys.

Props r-a-y. Fixes #6100. See #5733.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-profiledata.php

    r9139 r9336  
    3737        $d = new BP_XProfile_ProfileData( $f, $u );
    3838
    39         wp_cache_delete( $f, 'bp_xprofile_data_' . $u );
     39        wp_cache_delete( "{$u}:{$f}", 'bp_xprofile_data' );
    4040
    4141        $this->assertTrue( $d->exists() );
     
    5757        $c = new stdClass;
    5858        $c->id = 3;
    59         wp_cache_set( $f, $c, 'bp_xprofile_data_' . $u );
     59        wp_cache_set( "{$u}:{$f}", $c, 'bp_xprofile_data' );
    6060
    6161        $this->assertTrue( $d->exists() );
     
    7474
    7575        // Just to be sure
    76         wp_cache_delete( $f, 'bp_xprofile_data_' . $u );
     76        wp_cache_delete( "{$u}:{$f}", 'bp_xprofile_data' );
    7777
    7878        $this->assertEquals( 0, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) );
     
    9797
    9898        // Ensure it's deleted from cache
    99         wp_cache_delete( $f, 'bp_xprofile_data_' . $u );
     99        wp_cache_delete( "{$u}:{$f}", 'bp_xprofile_data' );
    100100
    101101        $this->assertEquals( $d->id, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) );
     
    116116        $d = new stdClass;
    117117        $d->id = 5;
    118         wp_cache_set( $f, $d, 'bp_xprofile_data_' . $u );
     118        wp_cache_set( "{$u}:{$f}", $d, 'bp_xprofile_data' );
    119119
    120120        $this->assertSame( 5, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) );
     
    139139
    140140        // Ensure it's deleted from cache
    141         wp_cache_delete( $f, 'bp_xprofile_data_' . $u );
     141        wp_cache_delete( "{$u}:{$f}", 'bp_xprofile_data' );
    142142
    143143        $this->assertSame( 'foo', BP_XProfile_ProfileData::get_value_byid( $f, $u ) );
     
    180180
    181181        // Ensure it's deleted from cache
    182         wp_cache_delete( $f, 'bp_xprofile_data_' . $u1 );
    183         wp_cache_delete( $f, 'bp_xprofile_data_' . $u2 );
     182        wp_cache_delete( "{$u1}:{$f}", 'bp_xprofile_data' );
     183        wp_cache_delete( "{$u2}:{$f}", 'bp_xprofile_data' );
    184184
    185185        $eu1 = new stdClass;
     
    219219        $d->value = 'foo';
    220220        $d->field_id = $f;
    221         wp_cache_set( $f, $d, 'bp_xprofile_data_' . $u );
     221        wp_cache_set( "{$u}:{$f}", $d, 'bp_xprofile_data' );
    222222
    223223        $this->assertSame( 'foo', BP_XProfile_ProfileData::get_value_byid( $f, $u ) );
     
    253253        $d2->last_updated = $time;
    254254
    255         wp_cache_set( $f, $d1, 'bp_xprofile_data_' . $u1 );
    256         wp_cache_set( $f, $d2, 'bp_xprofile_data_' . $u2 );
     255        wp_cache_set( "{$u1}:{$f}", $d1, 'bp_xprofile_data' );
     256        wp_cache_set( "{$u2}:{$f}", $d2, 'bp_xprofile_data' );
    257257
    258258        $eu1 = new stdClass;
     
    314314
    315315        // Ensure it's deleted from cache
    316         wp_cache_delete( $f1, 'bp_xprofile_data_' . $u );
    317         wp_cache_delete( $f2, 'bp_xprofile_data_' . $u );
     316        wp_cache_delete( "{$u}:{$f1}", 'bp_xprofile_data' );
     317        wp_cache_delete( "{$u}:{$f2}", 'bp_xprofile_data' );
    318318
    319319        $u_obj = new WP_User( $u );
     
    390390        $d2->id = 2;
    391391
    392         wp_cache_set( $f1, $d1, 'bp_xprofile_data_' . $u );
    393         wp_cache_set( $f2, $d2, 'bp_xprofile_data_' . $u );
     392        wp_cache_set( "{$u}:{$f1}", $d1, 'bp_xprofile_data' );
     393        wp_cache_set( "{$u}:{$f2}", $d2, 'bp_xprofile_data' );
    394394
    395395        $u_obj = new WP_User( $u );
Note: See TracChangeset for help on using the changeset viewer.