Skip to:
Content

BuddyPress.org

Changeset 1238 for trunk/bp-blogs.php


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.php

    r1227 r1238  
    466466            bp_blogs_record_post( $post_id );
    467467        }
     468       
     469        $recorded_post = $existing_post;
    468470    }
    469471
     
    623625    bp_blogs_delete_activity( array( 'item_id' => $post->blog_id, 'secondary_item_id' => $post->id, 'component_name' => 'blogs', 'component_action' => 'new_blog_post', 'user_id' => $post->user_id ) );
    624626
    625     do_action( 'bp_blogs_remove_post', $blog_id, $post_id );
     627    do_action( 'bp_blogs_remove_post', $blog_id, $post_id, $post->user_id );
    626628}
    627629add_action( 'delete_post', 'bp_blogs_remove_post' );
     
    643645    bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $comment_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_comment', 'user_id' => $bp->loggedin_user->id ) );
    644646
    645     do_action( 'bp_blogs_remove_comment', $blog_id, $comment_id );
     647    do_action( 'bp_blogs_remove_comment', $blog_id, $comment_id, $bp->loggedin_user->id );
    646648}
    647649add_action( 'delete_comment', 'bp_blogs_remove_comment' );
     
    834836add_action( 'wpmu_delete_user', 'bp_blogs_remove_data', 1 );
    835837add_action( 'delete_user', 'bp_blogs_remove_data', 1 );
     838
     839
     840function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
     841    wp_cache_delete( 'bp_user_blogs_' . $user_id, 'bp' );
     842}
     843
     844function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
     845    bp_blogs_clear_blog_object_cache( false, $recorded_blog_obj->user_id );
     846}
     847
     848function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) {
     849    wp_cache_delete( 'bp_user_posts_' . $user_id, 'bp' );
     850}
     851
     852function bp_blogs_format_clear_post_cache( $recorded_post_obj ) {
     853    bp_blogs_clear_post_object_cache( false, false, $recorded_post_obj->user_id );
     854}
     855
     856function bp_blogs_clear_comment_object_cache( $blog_id, $comment_id, $user_id ) {
     857    wp_cache_delete( 'bp_user_comments_' . $user_id, 'bp' );
     858}
     859
     860function bp_blogs_format_clear_comment_cache( $recorded_comment_obj ) {
     861    bp_blogs_clear_comment_object_cache( false, false, $recorded_comment_obj->user_id );
     862}
     863
     864// List actions to clear object caches on
     865add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
     866add_action( 'bp_blogs_remove_post', 'bp_blogs_clear_post_object_cache', 10, 3 );
     867add_action( 'bp_blogs_remove_comment', 'bp_blogs_clear_comment_object_cache', 10, 3 );
     868
     869add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
     870add_action( 'bp_blogs_new_blog_post', 'bp_blogs_format_clear_post_cache', 10, 2 );
     871add_action( 'bp_blogs_new_blog_comment', 'bp_blogs_format_clear_comment_cache', 10, 2 );
    836872
    837873// List actions to clear super cached pages on, if super cache is installed
     
    844880add_action( 'bp_blogs_new_blog_post', 'bp_core_clear_cache' );
    845881add_action( 'bp_blogs_new_blog', 'bp_core_clear_cache' );
    846 add_action( 'bp_blogs_new_blog', 'bp_core_clear_cache' );
    847882add_action( 'bp_blogs_remove_data', 'bp_core_clear_cache' );
    848883
Note: See TracChangeset for help on using the changeset viewer.