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-blogs/bp-blogs-templatetags.php

    r1052 r1238  
    2525
    2626        $this->blogs = bp_blogs_get_blogs_for_user( $user_id );
     27       
     28        if ( !$this->blogs = wp_cache_get( 'bp_user_blogs_' . $user_id, 'bp' ) ) {
     29            $this->blogs = bp_blogs_get_blogs_for_user( $user_id );
     30            wp_cache_set( 'bp_user_blogs_' . $user_id, $this->blogs, 'bp' );
     31        }
     32       
    2733        $this->total_blog_count = (int)$this->blogs['count'];
    2834        $this->blogs = $this->blogs['blogs'];
     
    141147        $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1;
    142148        $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 5;
    143 
    144         $this->posts = bp_blogs_get_posts_for_user( $user_id );
     149       
     150        if ( !$this->posts = wp_cache_get( 'bp_user_posts_' . $user_id, 'bp' ) ) {
     151            $this->posts = bp_blogs_get_posts_for_user( $user_id );
     152            wp_cache_set( 'bp_user_posts_' . $user_id, $this->posts, 'bp' );
     153        }
     154       
    145155        $this->total_post_count = (int)$this->posts['count'];
    146156        $this->posts = $this->posts['posts'];
     
    489499        $this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1;
    490500        $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 5;
    491 
    492         $this->comments = bp_blogs_get_comments_for_user( $user_id );
     501       
     502        if ( !$this->comments = wp_cache_get( 'bp_user_comments_' . $user_id, 'bp' ) ) {
     503            $this->comments = bp_blogs_get_comments_for_user( $user_id );
     504            wp_cache_set( 'bp_user_comments_' . $user_id, $this->comments, 'bp' );
     505        }
     506       
    493507        $this->total_comment_count = (int)$this->comments['count'];
    494508        $this->comments = $this->comments['comments'];
Note: See TracChangeset for help on using the changeset viewer.