Skip to:
Content

BuddyPress.org


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-core/bp-core-ajax.php

    r1197 r1238  
    88    switch ( $_POST['filter'] ) {
    99        case 'newest-members':
    10             $users = BP_Core_User::get_newest_users( $_POST['max-members'], 1 );
     10            if ( !$users = wp_cache_get( 'newest_users', 'bp' ) ) {
     11                $users = BP_Core_User::get_newest_users( $_POST['max-members'], 1 );
     12                wp_cache_set( 'newest_users', $users, 'bp' );
     13            }
    1114        break;
    1215        case 'recently-active-members':
    13             $users = BP_Core_User::get_active_users( $_POST['max-members'], 1 );
     16            if ( !$users = wp_cache_get( 'active_users', 'bp' ) ) {
     17                $users = BP_Core_User::get_active_users( $_POST['max-members'], 1 );
     18                wp_cache_set( 'active_users', $users, 'bp' );
     19            }
    1420        break;
    1521        case 'popular-members':
    16             $users = BP_Core_User::get_popular_users( $_POST['max-members'], 1 );
     22            if ( !$users = wp_cache_get( 'popular_users', 'bp' ) ) {
     23                $users = BP_Core_User::get_popular_users( $_POST['max-members'], 1 );
     24                wp_cache_set( 'popular_users', $users, 'bp' );
     25            }
    1726        break;
    1827    }
     
    117126               
    118127                    <div class="action">
    119                         <?php bp_add_friend_button( $user->user_id ) ?>
     128                        <?php if ( function_exists('bp_add_friend_button') ) : ?>
     129                            <?php bp_add_friend_button( $user->user_id ) ?>
     130                        <?php endif; ?>
    120131                        <div class="meta">
    121132                            <?php if ( $user_obj->total_friends ) echo $user_obj->total_friends ?><?php if ( $user_obj->total_blogs ) echo ', ' . $user_obj->total_blogs ?><?php if ( $user_obj->total_groups ) echo ', ' . $user_obj->total_groups ?>
Note: See TracChangeset for help on using the changeset viewer.