Make WordPress Core

Ticket #15812: 15812.suspend-caching.diff

File 15812.suspend-caching.diff, 1.8 KB (added by duck_, 11 years ago)
  • wp-includes/functions.php

     
    35313531}
    35323532
    35333533/**
     3534 * Suspend object caching.
     3535 *
     3536 * Stops wp_cache_add from adding objects to the cache. Useful for imports when the huge
     3537 * amount of data being added to cache isn't useful. Remember to call this again if you
     3538 * want suspension to only be temporary.
     3539 *
     3540 * @since 3.1.0
     3541 *
     3542 * @param bool $suspend Whether to suspend or enable caching
     3543 * @return bool The previous suspend setting
     3544 */
     3545function wp_suspend_caching( $suspend = true ) {
     3546        global $_wp_suspend_caching;
     3547       
     3548        $prev = $_wp_suspend_caching;
     3549        $_wp_suspend_caching = $suspend;
     3550        return $prev;
     3551}
     3552
     3553/**
    35343554 * Suspend cache invalidation.
    35353555 *
    35363556 * Turns cache invalidation on and off.  Useful during imports where you don't wont to do invalidations
     
    35403560 * @since 2.7.0
    35413561 *
    35423562 * @param bool $suspend Whether to suspend or enable cache invalidation
    3543  * @return bool The current suspend setting
     3563 * @return bool The previous suspend setting
    35443564 */
    3545 function wp_suspend_cache_invalidation($suspend = true) {
     3565function wp_suspend_cache_invalidation( $suspend = true ) {
    35463566        global $_wp_suspend_cache_invalidation;
    35473567
    35483568        $current_suspend = $_wp_suspend_cache_invalidation;
  • wp-includes/cache.php

     
    2222 * @return unknown
    2323 */
    2424function wp_cache_add($key, $data, $flag = '', $expire = 0) {
    25         global $wp_object_cache;
     25        global $wp_object_cache, $_wp_suspend_caching;
     26       
     27        if ( ! empty( $_wp_suspend_caching ) )
     28                return false;
    2629
    2730        return $wp_object_cache->add($key, $data, $flag, $expire);
    2831}