Make WordPress Core

Changeset 18681


Ignore:
Timestamp:
09/15/2011 08:23:00 PM (13 years ago)
Author:
duck_
Message:

Introduce wp_suspend_cache_addition() to allow reduced memory usage when cache additions aren't useful. Fixes #5389.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/cache.php

    r18659 r18681  
    295295     */
    296296    function add( $key, $data, $group = 'default', $expire = '' ) {
     297        if ( wp_suspend_cache_addition() )
     298            return false;
     299
    297300        if ( empty ($group) )
    298301            $group = 'default';
  • trunk/wp-includes/functions.php

    r18658 r18681  
    37113711
    37123712/**
     3713 * Temporarily suspend cache additions.
     3714 *
     3715 * Stops more data being added to the cache, but still allows cache retrieval.
     3716 * This is useful for actions, such as imports, when a lot of data would otherwise
     3717 * be almost uselessly added to the cache.
     3718 *
     3719 * Suspension lasts for a single page load at most. Remember to call this
     3720 * function again if you wish to re-enable cache adds earlier.
     3721 *
     3722 * @since 3.3.0
     3723 *
     3724 * @param bool $suspend Optional. Suspends additions if true, re-enables them if false.
     3725 * @return bool The current suspend setting
     3726 */
     3727function wp_suspend_cache_addition( $suspend = null ) {
     3728    static $_suspend = false;
     3729
     3730    if ( is_bool( $suspend ) )
     3731        $_suspend = $suspend;
     3732
     3733    return $_suspend;
     3734}
     3735
     3736/**
    37133737 * Suspend cache invalidation.
    37143738 *
Note: See TracChangeset for help on using the changeset viewer.