Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/26/2014 09:37:39 PM (11 years ago)
Author:
r-a-y
Message:

Add object caching when fetching the active notice.

This commit:

  • Introduces a new hook - 'messages_notice_before_delete' to do something before a notice is deleted
  • Adds object caching to the BP_Messages_Notice::get_active() method
  • Adds a cache invalidation function to bp-messages-cache.php
  • Adds a unit test

Fixes #5419

File:
1 edited

Legend:

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

    r6342 r7994  
    2323add_action( 'messages_screen_sentbox', 'bp_core_clear_cache' );
    2424add_action( 'messages_screen_inbox',   'bp_core_clear_cache' );
     25
     26/**
     27 * Invalidates cache for notices.
     28 *
     29 * Currently, invalidates active notice cache.
     30 *
     31 * @since BuddyPress (2.0.0)
     32 */
     33function bp_notices_clear_cache( $notice ) {
     34    wp_cache_delete( 'active_notice', 'bp_messages' );
     35}
     36add_action( 'messages_notice_after_save',    'bp_notices_clear_cache' );
     37add_action( 'messages_notice_before_delete', 'bp_notices_clear_cache' );
Note: See TracChangeset for help on using the changeset viewer.