Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/21/2014 05:51:10 PM (10 years ago)
Author:
boonebgorges
Message:

Overhaul the way that individual group objects are cached

The existing implementation was broken in a number of ways. Most critically,
user-specific data (like is_member) was being stored in the persistent object
cache without respect to user.

This refactor excludes the user-specific data from being cached along with the
group object. It also reworks the way that items are keyed in the cache, for
greater consistency with WordPress and the other BP components.

See #5407

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/groups/class-bp-groups-group.php

    r7938 r7956  
    644644
    645645    /**
     646     * @group delete
     647     * @group cache
     648     */
     649    public function test_delete_clear_cache() {
     650        $g = $this->factory->group->create();
     651
     652        // Prime cache
     653        groups_get_group( array( 'group_id' => $g, ) );
     654
     655        $this->assertNotEmpty( wp_cache_get( $g, 'bp_groups' ) );
     656
     657        $group = new BP_Groups_Group( $g );
     658        $group->delete();
     659
     660        $this->assertFalse( wp_cache_get( $g, 'bp_groups' ) );
     661    }
     662
     663    /**
     664     * @group save
     665     * @group cache
     666     */
     667    public function test_save_clear_cache() {
     668        $g = $this->factory->group->create();
     669
     670        // Prime cache
     671        groups_get_group( array( 'group_id' => $g, ) );
     672
     673        $this->assertNotEmpty( wp_cache_get( $g, 'bp_groups' ) );
     674
     675        $group = new BP_Groups_Group( $g );
     676        $group->name = 'Foo';
     677        $group->save();
     678
     679        $this->assertFalse( wp_cache_get( $g, 'bp_groups' ) );
     680    }
     681    /**
    646682     * @group get_group_extras
    647683     */
Note: See TracChangeset for help on using the changeset viewer.