Skip to:
Content

BuddyPress.org

Changeset 1238 for trunk/bp-xprofile.php


Ignore:
Timestamp:
03/19/2009 01:35:32 PM (16 years ago)
Author:
apeatling
Message:

Added basic object caching support ready for the first release. This will cut the number of database calls and load by 3x. Add define( 'WP_CACHE', true ); to you wp-config.php and drop object-cache.php into /wp-content/ to enable.

A good file based object cache is available here:
http://neosmart.net/dl.php?id=14

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile.php

    r1230 r1238  
    622622 * handling the save action.
    623623 *
    624  * [NOTE] This is old code that was written when support for the admin area was also
    625  * available. It is big and clunky and needs to be broken up.
     624 * [NOTE] This is old code that was written when editing was not done in the theme.
     625 * It is big and clunky and will be broken up in future versions.
    626626 *
    627627 * @package BuddyPress XProfile
     
    965965add_action( 'delete_user', 'xprofile_remove_data', 1 );
    966966
     967
     968function xprofile_clear_profile_groups_object_cache( $group_obj ) {
     969    wp_cache_delete( 'xprofile_groups', 'bp' );
     970    wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' );
     971    wp_cache_delete( 'xprofile_group_' . $group_obj->id );
     972}
     973
     974function xprofile_clear_profile_data_object_cache( $group_id ) {
     975    global $bp;
     976    wp_cache_delete( 'xprofile_fields_' . $group_id . '_' . $bp->loggedin_user->id, 'bp' );
     977    wp_cache_delete( 'online_users', 'bp' );
     978    wp_cache_delete( 'newest_users', 'bp' );
     979    wp_cache_delete( 'popular_users', 'bp' );
     980}
     981
     982// List actions to clear object caches on
     983add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' );
     984add_action( 'xprofile_groups_saved_group', 'xprofile_clear_profile_groups_object_cache' );
     985add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' );
     986
    967987// List actions to clear super cached pages on, if super cache is installed
    968988add_action( 'xprofile_updated_profile', 'bp_core_clear_cache' );
Note: See TracChangeset for help on using the changeset viewer.