當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wp_cache_phase2_clean_expired函數代碼示例

本文整理匯總了PHP中wp_cache_phase2_clean_expired函數的典型用法代碼示例。如果您正苦於以下問題:PHP wp_cache_phase2_clean_expired函數的具體用法?PHP wp_cache_phase2_clean_expired怎麽用?PHP wp_cache_phase2_clean_expired使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wp_cache_phase2_clean_expired函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wp_cache_clean_expired

function wp_cache_clean_expired($file_prefix)
{
    global $cache_path, $cache_max_time;
    // If phase2 was compiled, use its function to avoid race-conditions
    if (function_exists('wp_cache_phase2_clean_expired')) {
        if (function_exists('prune_super_cache')) {
            $dir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
            if (is_dir($dir)) {
                prune_super_cache($dir);
            } elseif (is_dir($dir . '.disabled')) {
                prune_super_cache($dir . '.disabled');
            }
            $_POST['super_cache_stats'] = 1;
            // regenerate super cache stats;
        }
        return wp_cache_phase2_clean_expired($file_prefix);
    }
    $expr = "/^{$file_prefix}/";
    $now = time();
    if ($handle = opendir($cache_path)) {
        while (false !== ($file = readdir($handle))) {
            if (preg_match($expr, $file) && filemtime($cache_path . $file) + $cache_max_time <= $now) {
                unlink($cache_path . $file);
                unlink($cache_path . 'meta/' . str_replace('.html', '.term', $file));
            }
        }
        closedir($handle);
    }
}
開發者ID:alx,項目名稱:alexgirard.com-blog,代碼行數:29,代碼來源:wp-cache.php

示例2: wp_cron_preload_cache


//.........這裏部分代碼省略.........
            $details = explode("\n", file_get_contents($taxonomy_filename));
        }
        if (count($details) != 1 && $details[0] != '') {
            $rows = array_splice($details, 0, 50);
            if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
                wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing %2$s taxonomy from %3$d to %4$d', 'wp-super-cache'), site_url(), $taxonomy, $c, $c + 100), 'Refreshing: ' . print_r($rows, 1));
            }
            foreach ((array) $rows as $url) {
                set_time_limit(60);
                if ($url == '') {
                    continue;
                }
                $url_info = parse_url($url);
                $dir = get_supercache_dir() . $url_info['path'];
                prune_super_cache($dir);
                $fp = @fopen($permalink_counter_msg, 'w');
                if ($fp) {
                    @fwrite($fp, "{$taxonomy}: {$url}");
                    @fclose($fp);
                }
                wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
                sleep(1);
            }
            $fp = fopen($taxonomy_filename, 'w');
            if ($fp) {
                fwrite($fp, implode("\n", $details));
                fclose($fp);
            }
        }
    }
    if ($wp_cache_preload_posts == 'all' || $c <= $wp_cache_preload_posts) {
        $posts = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE ( post_type != 'revision' AND post_type != 'nav_menu_item' ) AND post_status = 'publish' ORDER BY post_date DESC LIMIT {$c}, 100");
    } else {
        $posts = false;
    }
    if (!isset($wp_cache_preload_email_volume)) {
        $wp_cache_preload_email_volume = 'medium';
    }
    update_option('preload_cache_counter', array('c' => $c + 100, 't' => time()));
    if ($posts) {
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache'), site_url(), $c, $c + 100), ' ');
        }
        $msg = '';
        $count = $c + 1;
        $permalink_counter_msg = $cache_path . "preload_permalink.txt";
        foreach ($posts as $post_id) {
            set_time_limit(60);
            clear_post_supercache($post_id);
            $url = get_permalink($post_id);
            $fp = @fopen($permalink_counter_msg, 'w');
            if ($fp) {
                @fwrite($fp, $count . " " . $url);
                @fclose($fp);
            }
            if (@file_exists($cache_path . "stop_preload.txt")) {
                @unlink($mutex);
                @unlink($cache_path . "stop_preload.txt");
                update_option('preload_cache_counter', array('c' => 0, 't' => time()));
                if ($wp_cache_preload_email_me) {
                    wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Stopped', 'wp-super-cache'), site_url(), ''), ' ');
                }
                return true;
            }
            $msg .= "{$url}\n";
            wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
            sleep(1);
            $count++;
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume != 'less') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] %2$d posts refreshed', 'wp-super-cache'), $_SERVER['HTTP_HOST'], $c + 100), __("Refreshed the following posts:", 'wp-super-cache') . "\n{$msg}");
        }
        if (defined('DOING_CRON')) {
            wp_schedule_single_event(time() + 30, 'wp_cache_preload_hook');
        }
    } else {
        $msg = '';
        update_option('preload_cache_counter', array('c' => 0, 't' => time()));
        if ((int) $wp_cache_preload_interval && defined('DOING_CRON')) {
            if ($wp_cache_preload_email_me) {
                $msg = sprintf(__('Scheduling next preload refresh in %d minutes.', 'wp-super-cache'), (int) $wp_cache_preload_interval);
            }
            wp_schedule_single_event(time() + (int) $wp_cache_preload_interval * 60, 'wp_cache_full_preload_hook');
        }
        global $file_prefix, $cache_max_time;
        if ($wp_cache_preload_interval > 0) {
            $cache_max_time = (int) $wp_cache_preload_interval * 60;
            // fool the GC into expiring really old files
        } else {
            $cache_max_time = 86400;
            // fool the GC into expiring really old files
        }
        if ($wp_cache_preload_email_me) {
            wp_mail(get_option('admin_email'), sprintf(__('[%s] Cache Preload Completed', 'wp-super-cache'), site_url()), __("Cleaning up old supercache files.", 'wp-super-cache') . "\n" . $msg);
        }
        wp_cache_phase2_clean_expired($file_prefix, true);
        // force cleanup of old files.
    }
    @unlink($mutex);
}
開發者ID:popovdenis,項目名稱:kmst,代碼行數:101,代碼來源:wp-cache.php

示例3: wp_cache_gc_cron

function wp_cache_gc_cron()
{
    global $file_prefix, $cache_max_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();
    if (!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_max_time - 10));
        // if GC failed then run it again in one minute
    }
    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);
        }
    }
}
開發者ID:jeremylightsmith,項目名稱:blog,代碼行數:23,代碼來源:wp-cache-phase2.php

示例4: wp_cron_preload_cache


//.........這裏部分代碼省略.........
                        wp_cache_debug("wp_cron_preload_cache: fetched {$url}", 5);
                        sleep(1);
                    }
                    $fp = fopen($taxonomy_filename, 'w');
                    if ($fp) {
                        fwrite($fp, implode("\n", $details));
                        fclose($fp);
                    }
                }
            }
        }
    }
    if ($wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts) {
        $types = get_post_types(array('public' => true, 'publicly_queryable' => true), 'names', 'or');
        $types = array_map('esc_sql', $types);
        $types = "'" . implode("','", $types) . "'";
        $posts = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE ( post_type IN ( {$types} ) ) AND post_status = 'publish' ORDER BY ID ASC LIMIT {$c}, 100");
        wp_cache_debug("wp_cron_preload_cache: got 100 posts from position {$c}.", 5);
    } else {
        wp_cache_debug("wp_cron_preload_cache: no more posts to get. Limit ({$wp_cache_preload_posts}) reached.", 5);
        $posts = false;
    }
    if (!isset($wp_cache_preload_email_volume)) {
        $wp_cache_preload_email_volume = 'medium';
    }
    if ($posts) {
        if (get_option('show_on_front') == 'page') {
            $page_on_front = get_option('page_on_front');
            $page_for_posts = get_option('page_for_posts');
        } else {
            $page_on_front = $page_for_posts = 0;
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache'), home_url(), $c, $c + 100), ' ');
        }
        $msg = '';
        $count = $c + 1;
        $permalink_counter_msg = $cache_path . "preload_permalink.txt";
        foreach ($posts as $post_id) {
            set_time_limit(60);
            if ($page_on_front != 0 && ($post_id == $page_on_front || $post_id == $page_for_posts)) {
                continue;
            }
            clear_post_supercache($post_id);
            $url = get_permalink($post_id);
            $fp = @fopen($permalink_counter_msg, 'w');
            if ($fp) {
                @fwrite($fp, $count . " " . $url);
                @fclose($fp);
            }
            if (@file_exists($cache_path . "stop_preload.txt")) {
                wp_cache_debug("wp_cron_preload_cache: cancelling preload. stop_preload.txt found.", 5);
                @unlink($mutex);
                @unlink($cache_path . "stop_preload.txt");
                update_option('preload_cache_counter', array('c' => 0, 't' => time()));
                if ($wp_cache_preload_email_me) {
                    wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Stopped', 'wp-super-cache'), home_url(), ''), ' ');
                }
                return true;
            }
            $msg .= "{$url}\n";
            wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
            wp_cache_debug("wp_cron_preload_cache: fetched {$url}", 5);
            sleep(1);
            $count++;
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume != 'less') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] %2$d posts refreshed', 'wp-super-cache'), home_url(), $c + 100), __("Refreshed the following posts:", 'wp-super-cache') . "\n{$msg}");
        }
        if (defined('DOING_CRON')) {
            wp_cache_debug("wp_cron_preload_cache: scheduling the next preload in 30 seconds.", 5);
            wp_schedule_single_event(time() + 30, 'wp_cache_preload_hook');
        }
    } else {
        $msg = '';
        update_option('preload_cache_counter', array('c' => 0, 't' => time()));
        if ((int) $wp_cache_preload_interval && defined('DOING_CRON')) {
            if ($wp_cache_preload_email_me) {
                $msg = sprintf(__('Scheduling next preload refresh in %d minutes.', 'wp-super-cache'), (int) $wp_cache_preload_interval);
            }
            wp_cache_debug("wp_cron_preload_cache: no more posts. scheduling next preload in {$wp_cache_preload_interval} minutes.", 5);
            wp_schedule_single_event(time() + (int) $wp_cache_preload_interval * 60, 'wp_cache_full_preload_hook');
        }
        global $file_prefix, $cache_max_time;
        if ($wp_cache_preload_interval > 0) {
            $cache_max_time = (int) $wp_cache_preload_interval * 60;
            // fool the GC into expiring really old files
        } else {
            $cache_max_time = 86400;
            // fool the GC into expiring really old files
        }
        if ($wp_cache_preload_email_me) {
            wp_mail(get_option('admin_email'), sprintf(__('[%s] Cache Preload Completed', 'wp-super-cache'), home_url()), __("Cleaning up old supercache files.", 'wp-super-cache') . "\n" . $msg);
        }
        wp_cache_debug("wp_cron_preload_cache: clean expired cache files older than {$cache_max_time} seconds.", 5);
        wp_cache_phase2_clean_expired($file_prefix, true);
        // force cleanup of old files.
    }
    @unlink($mutex);
}
開發者ID:jordankoschei,項目名稱:jordankoschei-dot-com,代碼行數:101,代碼來源:wp-cache.php

示例5: wp_cron_preload_cache

function wp_cron_preload_cache()
{
    global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume;
    if (get_option('preload_cache_stop')) {
        delete_option('preload_cache_stop');
        return true;
    }
    $c = (int) get_option('preload_cache_counter');
    if ($wp_cache_preload_posts == 'all' || $c <= $wp_cache_preload_posts) {
        $posts = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT {$c}, 100");
    } else {
        $posts = false;
    }
    if (!isset($wp_cache_preload_email_volume)) {
        $wp_cache_preload_email_volume = 'medium';
    }
    update_option('preload_cache_counter', $c + 100);
    if ($posts) {
        if ($wp_cache_preload_email_me && $c == 0) {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Started', 'wp-super-cache'), site_url(), ''), '');
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache'), site_url(), $c, $c + 100), '');
        }
        $msg = '';
        $count = $c + 1;
        foreach ($posts as $post_id) {
            clear_post_supercache($post_id);
            $url = get_permalink($post_id);
            $msg .= "{$url}\n";
            wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
            $count++;
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume != 'less') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] %2$d posts refreshed', 'wp-super-cache'), $_SERVER['HTTP_HOST'], $c + 100), __("Refreshed the following posts:", 'wp-super-cache') . "\n{$msg}");
        }
        if (defined('DOING_CRON')) {
            wp_schedule_single_event(time() + 30, 'wp_cache_preload_hook');
        }
    } else {
        $msg = '';
        update_option('preload_cache_counter', 0);
        if ((int) $wp_cache_preload_interval && defined('DOING_CRON')) {
            if ($wp_cache_preload_email_me) {
                $msg = sprintf(__('Scheduling next preload refresh in %d minutes.', 'wp-super-cache'), (int) $wp_cache_preload_interval);
            }
            wp_schedule_single_event(time() + (int) $wp_cache_preload_interval * 60, 'wp_cache_full_preload_hook');
        }
        global $file_prefix, $cache_max_time;
        if ($wp_cache_preload_interval > 0) {
            $cache_max_time = (int) $wp_cache_preload_interval * 60;
            // fool the GC into expiring really old files
        } else {
            $cache_max_time = 86400;
            // fool the GC into expiring really old files
        }
        if ($wp_cache_preload_email_me) {
            wp_mail(get_option('admin_email'), sprintf(__('[%s] Cache Preload Completed', 'wp-super-cache'), site_url()), __("Cleaning up old supercache files.", 'wp-super-cache') . "\n" . $msg);
        }
        wp_cache_phase2_clean_expired($file_prefix, true);
        // force cleanup of old files.
    }
}
開發者ID:hoonio,項目名稱:wordpress,代碼行數:63,代碼來源:wp-cache.php

示例6: wp_cache_ob_end

function wp_cache_ob_end()
{
    global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache;
    global $meta_object, $known_headers;
    /* Preparing... with PHP5 is straightforward, use headers_list() */
    if (function_exists('apache_response_headers')) {
        $response = apache_response_headers();
        $meta_object->headers = array();
        foreach ($known_headers as $key) {
            if (isset($response[$key])) {
                array_push($meta_object->headers, "{$key}: " . $response[$key]);
            }
        }
        /* Not use because it gives problems with some
        		 * PHP installations
        		if (!$response{'Content-Length'}) {
        		// WP does not set content size
        			$content_size = ob_get_length();
        			@header("Content-Length: $content_size");
        			array_push($meta_object->headers, "Content-Length: $content_size");
        		}
        		*/
        if (!$response['Last-Modified']) {
            $value = gmdate('D, d M Y H:i:s') . ' GMT';
            /* Dont send this the first time */
            /* @header('Last-Modified: ' . $value); */
            array_push($meta_object->headers, "Last-Modified: {$value}");
        }
        if (!$response['Content-Type']) {
            $value = "text/html; charset=\"" . get_settings('blog_charset') . "\"";
            @header("Content-Type: {$value}");
            array_push($meta_object->headers, "Content-Type: {$value}");
        }
    }
    ob_end_clean();
    if ($new_cache) {
        $serial = serialize($meta_object);
        wp_cache_writers_entry();
        $fr = fopen($cache_path . $meta_file, 'w');
        fputs($fr, $serial);
        fclose($fr);
        wp_cache_writers_exit();
    }
    if ($file_expired == false) {
        return;
    }
    // we delete expired files
    flush();
    //Ensure we send data to the client
    wp_cache_phase2_clean_expired($file_prefix);
}
開發者ID:sajidsan,項目名稱:sajidsan.github.io,代碼行數:51,代碼來源:wp-cache-phase2.php

示例7: wp_cache_gc_cron

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);
}
開發者ID:rubyerme,項目名稱:rubyerme.github.com,代碼行數:42,代碼來源:wp-cache-phase2.php

示例8: wp_cache_clean_expired

function wp_cache_clean_expired($file_prefix)
{
    global $cache_path, $cache_max_time;
    // If phase2 was compiled, use its function to avoid race-conditions
    if (function_exists('wp_cache_phase2_clean_expired')) {
        return wp_cache_phase2_clean_expired($file_prefix);
    }
    $expr = "/^{$file_prefix}/";
    $now = time();
    if ($handle = opendir($cache_path)) {
        while (false !== ($file = readdir($handle))) {
            if (preg_match($expr, $file) && filemtime($cache_path . $file) + $cache_max_time <= $now) {
                unlink($cache_path . $file);
            }
        }
        closedir($handle);
    }
}
開發者ID:jeremyboles,項目名稱:cappuccino-website,代碼行數:18,代碼來源:wp-cache.php

示例9: wp_cache_shutdown_callback

function wp_cache_shutdown_callback()
{
    global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache;
    global $wp_cache_meta_object, $known_headers, $blog_id;
    $wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"] . preg_replace('/[ <>\'\\"\\r\\n\\t\\(\\)]/', '', $_SERVER['REQUEST_URI']);
    // To avoid XSS attacs
    $wp_cache_meta_object->blog_id = $blog_id;
    $wp_cache_meta_object->post = wp_cache_post_id();
    $response = wp_cache_get_response_headers();
    $wp_cache_meta_object->headers = array();
    foreach ($known_headers as $key) {
        if (isset($response[$key])) {
            array_push($wp_cache_meta_object->headers, "{$key}: " . $response[$key]);
        }
    }
    /* Not used because it gives problems with some
    	 * PHP installations
    	if (!$response{'Content-Length'}) {
    	// WP does not set content size
    		$content_size = ob_get_length();
    		@header("Content-Length: $content_size");
    		array_push($wp_cache_meta_object->headers, "Content-Length: $content_size");
    	}
    	*/
    if (!$response['Last-Modified']) {
        $value = gmdate('D, d M Y H:i:s') . ' GMT';
        /* Dont send this the first time */
        /* @header('Last-Modified: ' . $value); */
        array_push($wp_cache_meta_object->headers, "Last-Modified: {$value}");
    }
    if (!$response['Content-Type'] && !$response['Content-type']) {
        $value = "text/html; charset=" . get_settings('blog_charset');
        @header("Content-Type: {$value}");
        array_push($wp_cache_meta_object->headers, "Content-Type: {$value}");
    }
    ob_end_flush();
    if ($new_cache) {
        $serial = serialize($wp_cache_meta_object);
        wp_cache_writers_entry();
        $fr = fopen($cache_path . $meta_file, 'w');
        fputs($fr, $serial);
        fclose($fr);
        wp_cache_writers_exit();
    }
    if ($file_expired == false) {
        return;
    }
    // we delete expired files
    flush();
    //Ensure we send data to the client
    wp_cache_phase2_clean_expired($file_prefix);
}
開發者ID:ryan-allen,項目名稱:w1000-super-total-mega-shark-cache-on-a-boat-on-a-plane,代碼行數:52,代碼來源:wp-cache-phase2.php

示例10: wp_cron_preload_cache

function wp_cron_preload_cache()
{
    global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $cache_path;
    if (get_option('preload_cache_stop')) {
        delete_option('preload_cache_stop');
        return true;
    }
    $mutex = $cache_path . "preload_mutex.tmp";
    sleep(3 + mt_rand(1, 5));
    if (@file_exists($mutex)) {
        if (@filemtime($mutex) > time() - 600) {
            return true;
        } else {
            @unlink($mutex);
        }
    }
    $fp = @fopen($mutex, 'w');
    @fclose($fp);
    $counter = get_option('preload_cache_counter');
    $c = $counter['c'];
    if ($wp_cache_preload_posts == 'all' || $c <= $wp_cache_preload_posts) {
        $posts = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE (post_type = 'post' OR post_type='page') AND post_status = 'publish' ORDER BY post_date DESC LIMIT {$c}, 100");
    } else {
        $posts = false;
    }
    if (!isset($wp_cache_preload_email_volume)) {
        $wp_cache_preload_email_volume = 'medium';
    }
    update_option('preload_cache_counter', array('c' => $c + 100, 't' => time()));
    if ($posts) {
        if ($wp_cache_preload_email_me && $c == 0) {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Started', 'wp-super-cache'), site_url(), ''), '');
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache'), site_url(), $c, $c + 100), '');
        }
        $msg = '';
        $count = $c + 1;
        $permalink_counter_msg = $cache_path . "preload_permalink.txt";
        foreach ($posts as $post_id) {
            set_time_limit(60);
            clear_post_supercache($post_id);
            $url = get_permalink($post_id);
            $fp = @fopen($permalink_counter_msg, 'w');
            if ($fp) {
                @fwrite($fp, $count . " " . $url);
                @fclose($fp);
            }
            if (@file_exists($cache_path . "stop_preload.txt")) {
                @unlink($mutex);
                @unlink($cache_path . "stop_preload.txt");
                update_option('preload_cache_counter', array('c' => 0, 't' => time()));
                if ($wp_cache_preload_email_me) {
                    wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Stopped', 'wp-super-cache'), site_url(), ''), '');
                }
                return true;
            }
            $msg .= "{$url}\n";
            wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
            sleep(1);
            $count++;
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume != 'less') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] %2$d posts refreshed', 'wp-super-cache'), $_SERVER['HTTP_HOST'], $c + 100), __("Refreshed the following posts:", 'wp-super-cache') . "\n{$msg}");
        }
        if (defined('DOING_CRON')) {
            wp_schedule_single_event(time() + 30, 'wp_cache_preload_hook');
        }
    } else {
        $msg = '';
        update_option('preload_cache_counter', array('c' => 0, 't' => time()));
        if ((int) $wp_cache_preload_interval && defined('DOING_CRON')) {
            if ($wp_cache_preload_email_me) {
                $msg = sprintf(__('Scheduling next preload refresh in %d minutes.', 'wp-super-cache'), (int) $wp_cache_preload_interval);
            }
            wp_schedule_single_event(time() + (int) $wp_cache_preload_interval * 60, 'wp_cache_full_preload_hook');
        }
        global $file_prefix, $cache_max_time;
        if ($wp_cache_preload_interval > 0) {
            $cache_max_time = (int) $wp_cache_preload_interval * 60;
            // fool the GC into expiring really old files
        } else {
            $cache_max_time = 86400;
            // fool the GC into expiring really old files
        }
        if ($wp_cache_preload_email_me) {
            wp_mail(get_option('admin_email'), sprintf(__('[%s] Cache Preload Completed', 'wp-super-cache'), site_url()), __("Cleaning up old supercache files.", 'wp-super-cache') . "\n" . $msg);
        }
        wp_cache_phase2_clean_expired($file_prefix, true);
        // force cleanup of old files.
    }
    @unlink($mutex);
}
開發者ID:JeffLuckett,項目名稱:quickref,代碼行數:93,代碼來源:wp-cache.php

示例11: wp_cache_gc_cron

function wp_cache_gc_cron()
{
    global $file_prefix, $wp_cache_gc;
    if (!isset($wp_cache_gc)) {
        $wp_cache_gc = 3600;
    }
    if (!wp_cache_phase2_clean_expired($file_prefix)) {
        update_option('wpsupercache_gc_time', time() - ($wp_cache_gc - 600));
    }
    // if GC failed then run it again in 10 minutes
}
開發者ID:alx,項目名稱:barceloneta,代碼行數:11,代碼來源:wp-cache-phase2.php

示例12: wp_cache_gc_cron

function wp_cache_gc_cron()
{
    global $file_prefix;
    wp_cache_phase2_clean_expired($file_prefix);
}
開發者ID:alx,項目名稱:alexgirard.com-blog,代碼行數:5,代碼來源:wp-cache-phase2.php


注:本文中的wp_cache_phase2_clean_expired函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。