Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/06/2014 06:58:17 PM (12 years ago)
Author:
boonebgorges
Message:

Store directory_pages data in the persistent cache.

This information is needed during every bootstrap, yet rarely changes, so there
should be significant performance benefit from caching it.

Invalidation takes place when one of the pages is updated, or when the bp-pages
option is changed.

Note that this change will likely be moot after migrating to the WP rewrite
API. See #4954.

See #5362

Props Denis-de-Bernardy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-cache.php

    r7786 r7809  
    5656add_action( 'bp_first_activity_for_member',   'bp_core_clear_member_count_caches' );
    5757add_action( 'deleted_user',                   'bp_core_clear_member_count_caches' );
     58
     59/**
     60 * Clear the directory_pages cache when one of the pages is updated.
     61 *
     62 * @since BuddyPress (2.0.0)
     63 *
     64 * @param int $post_id
     65 */
     66function bp_core_clear_directory_pages_cache_page_edit( $post_id ) {
     67        if ( ! bp_is_root_blog() ) {
     68                return;
     69        }
     70
     71        // Bail if BP is not defined here
     72        if ( ! buddypress() ) {
     73                return;
     74        }
     75
     76        $page_ids = bp_core_get_directory_page_ids();
     77
     78        if ( ! in_array( $post_id, (array) $page_ids ) ) {
     79                return;
     80        }
     81
     82        wp_cache_delete( 'directory_pages', 'bp' );
     83}
     84add_action( 'save_post_page', 'bp_core_clear_directory_pages_cache_page_edit' );
     85
     86/**
     87 * Clear the directory_pages cache when the bp-pages option is updated.
     88 *
     89 * @since BuddyPress (2.0.0)
     90 */
     91function bp_core_clear_directory_pages_cache_settings_edit() {
     92        wp_cache_delete( 'directory_pages', 'bp' );
     93}
     94add_action( 'update_option_bp-pages', 'bp_core_clear_directory_pages_cache_settings_edit' );
    5895
    5996/**
Note: See TracChangeset for help on using the changeset viewer.