Skip to:
Content

BuddyPress.org

Changeset 5505


Ignore:
Timestamp:
12/11/2011 04:58:11 PM (13 years ago)
Author:
boonebgorges
Message:

Collect and cache activity meta at the beginning of the activity loop, for quicker lookups. Fixes #3814

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-classes.php

    r5484 r5505  
    5151            $this->mptt_right        = $row->mptt_right;
    5252            $this->is_spam           = $row->is_spam;
     53           
     54            bp_activity_update_meta_cache( $this->id );
    5355        }
    5456    }
     
    190192                }
    191193            }
     194        }
     195       
     196        // Get activity meta
     197        $activity_ids = array();
     198        foreach ( (array)$activities as $activity ) {
     199            $activity_ids[] = $activity->id;
     200        }
     201       
     202        if ( !empty( $activity_ids ) ) {
     203            bp_activity_update_meta_cache( $activity_ids );
    192204        }
    193205
  • trunk/bp-activity/bp-activity-functions.php

    r5437 r5505  
    483483
    484484    // Delete cache entry
    485     wp_cache_delete( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' );
     485    wp_cache_delete( 'bp_activity_meta_' . $activity_id . '_' . $meta_key, 'bp' );
    486486
    487487    // Success
     
    524524
    525525        // Check cache
    526         if ( !$metas = wp_cache_get( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' ) ) {
     526        if ( !$metas = wp_cache_get( 'bp_activity_meta_' . $activity_id . '_' . $meta_key, 'bp' ) ) {
     527            var_dump( 'miss' );
    527528
    528529            // No cache so hit the DB
     
    530531
    531532            // Set cache
    532             wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $metas, 'bp' );
     533            wp_cache_set( 'bp_activity_meta_' . $activity_id . '_' . $meta_key, $metas, 'bp' );
    533534        }
    534535
     
    606607
    607608    // Set cache
    608     wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $meta_value, 'bp' );
     609    wp_cache_set( 'bp_activity_meta_' . $activity_id . '_' . $meta_key, $meta_value, 'bp' );
    609610
    610611    // Victory is ours!
  • trunk/bp-activity/bp-activity-loader.php

    r5477 r5505  
    4848            'functions',
    4949            'notifications',
     50            'cache'
    5051        );
    5152
  • trunk/bp-core/bp-core-cache.php

    r5460 r5505  
    9696    // Get meta info
    9797    $id_list   = join( ',', $object_ids );
    98     $meta_list = $wpdb->get_results( $wpdb->prepare( "SELECT $object_column, meta_key, meta_value FROM $meta_table WHERE group_id IN ($id_list)" ), ARRAY_A );
     98    $meta_list = $wpdb->get_results( $wpdb->prepare( "SELECT $object_column, meta_key, meta_value FROM $meta_table WHERE $object_column IN ($id_list)" ), ARRAY_A );
    9999
    100100    if ( !empty( $meta_list ) ) {
Note: See TracChangeset for help on using the changeset viewer.