wp_cache_phase2_clean_expired()WPSCache 1.0

No Hooks.

Return

null. Nothing.

Usage

wp_cache_phase2_clean_expired( $file_prefix, $force );
$file_prefix (required)
-
$force **
-
Default: false

Code of wp_cache_phase2_clean_expired() WPSCache 1.8

function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
	global $cache_path, $cache_max_time, $blog_cache_dir, $wp_cache_preload_on;

	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;
	}
	$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;
}