Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/19/2009 01:35:32 PM (17 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-friends/bp-friends-templatetags.php

    r1205 r1238  
    106106                } else {
    107107                        $this->friendship = (object) $this->friendship;
    108                         $this->friendship->friend = new BP_Core_User( $this->friendship->user_id );
     108                       
     109                        if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $this->friendship->user_id, 'bp' ) ) {
     110                                $this->friendship->friend = new BP_Core_User( $this->friendship->user_id );
     111                                wp_cache_set( 'bp_user_' . $this->friendship->user_id, $this->friendship->friend, 'bp' );
     112                        }
    109113                }
    110114               
     
    339343        global $bp;
    340344       
    341         $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );
     345        if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) {
     346                $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );
     347                wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' );
     348        }
    342349?>     
    343350        <div class="info-group">
     
    366373        global $bp;
    367374       
    368         $user_ids = BP_Core_User::get_random_users( $total_members );
     375        if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
     376                $user_ids = BP_Core_User::get_random_users( $total_members );
     377                wp_cache_set( 'friends_random_users', $user_ids, 'bp' );
     378        }
    369379?>     
    370380        <?php if ( $user_ids['users'] ) { ?>
Note: See TracChangeset for help on using the changeset viewer.