wp_cache_phase2_clean_expired()
No Hooks.
Return
null
. Nothing (null).
Usage
wp_cache_phase2_clean_expired( $file_prefix, $force );
- $file_prefix (required)
- -
- $force **
- -
Default: false
wp_cache_phase2_clean_expired() wp cache phase2 clean expired code WPSCache 1.12.4
function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) { global $cache_path, $cache_max_time, $blog_cache_dir, $wp_cache_preload_on, $wp_cache_debug_log; if ( $cache_max_time == 0 ) { wp_cache_debug( 'wp_cache_phase2_clean_expired: disabled because GC disabled.', 2 ); return false; } clearstatcache(); if ( ! wp_cache_writers_entry() ) { return false; } // make sure we have a debug log viewer if ( empty( $wp_cache_debug_log ) ) { wpsc_create_debug_log(); } else { touch( $cache_path . 'view_' . $wp_cache_debug_log ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_touch } $now = time(); wp_cache_debug( "Cleaning expired cache files in $blog_cache_dir", 2 ); $deleted = 0; if ( ( $handle = @opendir( $blog_cache_dir ) ) ) { while ( false !== ( $file = readdir( $handle ) ) ) { if ( preg_match( "/^$file_prefix/", $file ) && ( @filemtime( $blog_cache_dir . $file ) + $cache_max_time ) <= $now ) { @unlink( $blog_cache_dir . $file ); @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) ); wp_cache_debug( "wp_cache_phase2_clean_expired: Deleting obsolete wpcache cache+meta files: $file" ); continue; } if ( $file != '.' && $file != '..' ) { if ( is_dir( $blog_cache_dir . $file ) == false && ( @filemtime( $blog_cache_dir . $file ) + $cache_max_time ) <= $now ) { if ( substr( $file, -9 ) != '.htaccess' && $file != 'index.html' ) { @unlink( $blog_cache_dir . $file ); wp_cache_debug( "Deleting $blog_cache_dir{$file}, older than $cache_max_time seconds", 5 ); } } } } closedir( $handle ); if ( false == $wp_cache_preload_on || true == $force ) { wp_cache_debug( "Doing GC on supercache dir: {$cache_path}supercache", 2 ); $deleted = prune_super_cache( $cache_path . 'supercache', false, false ); } } wp_cache_writers_exit(); return $deleted; }