WordPress.org

Plugin Directory

Changeset 579031


Ignore:
Timestamp:
07/30/12 09:01:01 (21 months ago)
Author:
donncha
Message:

Use GC flag wp_cache_gc.txt in cache directory so watcher job doesn't schedule a GC when it's already running

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-super-cache/trunk/wp-cache-phase2.php

    r579023 r579031  
    11951195} 
    11961196 
     1197function maybe_stop_gc() { 
     1198    global $cache_path; 
     1199 
     1200    if ( @file_exists( $cache_path . 'wp_cache_gc.txt' ) ) { 
     1201        if ( filemtime( $cache_path . 'wp_cache_gc.txt' ) > 600 ) { 
     1202            @unlink( $cache_path . 'wp_cache_gc.txt' ); 
     1203            if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "maybe_stop_gc: GC flag found but deleted because it's older than 600 seconds.", 5 ); 
     1204            return false; 
     1205        } else { 
     1206            if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'maybe_stop_gc: GC flag found. GC cancelled.', 5 ); 
     1207            return true; 
     1208        } 
     1209    } else { 
     1210        if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'maybe_stop_gc: GC flag not found. GC will go ahead..', 5 ); 
     1211        return false; 
     1212    } 
     1213} 
     1214 
    11971215function wp_cache_gc_cron() { 
    11981216    global $file_prefix, $cache_max_time, $cache_gc_email_me, $cache_time_interval; 
     
    12031221        return false; 
    12041222    } 
     1223 
     1224    if ( maybe_stop_gc() ) { 
     1225        if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'GC flag found. GC cancelled.', 5 ); 
     1226        return false; 
     1227    } 
     1228 
    12051229    update_option( 'wpsupercache_gc_time', time() );  
     1230    $fp = @fopen( $cache_path . "wp_cache_gc.txt", 'w' ); 
     1231    @fclose( $fp ); 
    12061232 
    12071233    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Cache garbage collection.', 5 ); 
     
    12301256        wp_mail( get_option( 'admin_email' ), sprintf( __( '[%1$s] WP Super Cache GC Report', 'wp-super-cache' ), site_url() ), $msg ); 
    12311257    } 
     1258    @unlink( $cache_path . 'wp_cache_gc.txt' ); 
     1259    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'GC completed. GC flag deleted.', 5 ); 
    12321260    schedule_wp_gc( 1 ); 
    12331261} 
Note: See TracChangeset for help on using the changeset viewer.