예제 #1
0
function wp_cache_gc_watcher()
{
    if (false == wp_next_scheduled('wp_cache_gc')) {
        wp_cache_debug('GC Watcher: scheduled new gc cron.', 5);
        schedule_wp_gc();
    }
}
function wp_cache_gc_cron()
{
    global $file_prefix, $cache_max_time, $cache_gc_email_me, $cache_time_interval;
    $msg = '';
    if ($cache_max_time == 0) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Cache garbage collection disabled because cache expiry time is zero.', 5);
        }
        return false;
    }
    update_option('wpsupercache_gc_time', time());
    if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
        wp_cache_debug('Cache garbage collection.', 5);
    }
    if (!isset($cache_max_time)) {
        $cache_max_time = 600;
    }
    $start = time();
    $num = 0;
    if (false == ($num = wp_cache_phase2_clean_expired($file_prefix))) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('Cache Expiry cron job failed. Probably mutex locked.', 1);
        }
        update_option('wpsupercache_gc_time', time() - ($cache_time_interval - 10));
        // if GC failed then run it again in one minute
        $msg .= __('Cache expiry cron job failed. Job will run again in 10 seconds.', 'wp-super-cache') . "\n";
    }
    if (time() - $start > 30) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("Cache Expiry cron job took more than 30 seconds to execute.\nYou should reduce the Expiry Time in the WP Super Cache admin page\nas you probably have more cache files than your server can handle efficiently.", 1);
        }
        $msg .= __('Cache expiry cron job took more than 30 seconds. You should probably run the garbage collector more often.', 'wp-super-cache') . "\n";
    }
    if ($cache_gc_email_me) {
        if ($msg != '') {
            $msg = "The following warnings were generated by the WP Super Cache Garbage Collector:\n" . $msg;
        }
        $msg = "Hi,\n\nThe WP Super Cache Garbage Collector has now run, deleting " . (int) $num . " files and directories.\nIf you want to switch off these emails please see the WP Super Cache Advanced Settings\npage on your blog.\n\n{$msg}\nRegards,\nThe Garbage Collector.";
        wp_mail(get_option('admin_email'), sprintf(__('[%1$s] WP Super Cache GC Report', 'wp-super-cache'), site_url()), $msg);
    }
    schedule_wp_gc(1);
}
예제 #3
0
function wp_cache_gc_watcher()
{
    if (false == wp_next_scheduled('wp_cache_gc')) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug('GC Watcher: scheduled new gc cron.', 5);
        }
        schedule_wp_gc();
    }
}