wp_cache_phase2_clean_cache()WPSCache 1.0

Hooks from the function

Return

null. Nothing.

Usage

wp_cache_phase2_clean_cache( $file_prefix );
$file_prefix (required)
-

Code of wp_cache_phase2_clean_cache() WPSCache 1.9

function wp_cache_phase2_clean_cache( $file_prefix ) {
	global $wpdb, $blog_cache_dir;

	if ( ! wp_cache_writers_entry() ) {
		return false;
	}
	wp_cache_debug( "wp_cache_phase2_clean_cache: Cleaning cache in $blog_cache_dir" );
	if ( $handle = @opendir( $blog_cache_dir ) ) {
		while ( false !== ( $file = @readdir( $handle ) ) ) {
			if ( strpos( $file, $file_prefix ) !== false ) {
				if ( strpos( $file, '.html' ) ) {
					// delete old wpcache files immediately
					wp_cache_debug( "wp_cache_phase2_clean_cache: Deleting obsolete wpcache cache+meta files: $file" );
					@unlink( $blog_cache_dir . $file );
					@unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
				} else {
					$meta = json_decode( wp_cache_get_legacy_cache( $blog_cache_dir . 'meta/' . $file ), true );
					if ( $meta['blog_id'] == $wpdb->blogid ) {
						@unlink( $blog_cache_dir . $file );
						@unlink( $blog_cache_dir . 'meta/' . $file );
					}
				}
			}
		}
		closedir( $handle );
		do_action( 'wp_cache_cleared' );
	}
	wp_cache_writers_exit();
}