php/WP_CLI/FileCache.php
public function prune() {
		if ( ! $this->enabled ) {
			return false;
		}

		/** @var Finder $finder */
		$finder = $this->get_finder()->sortByName();

		$files_to_delete = array();

		foreach ( $finder as $file ) {
			$pieces    = explode( '-', $file->getBasename( $file->getExtension() ) );
			$timestamp = end( $pieces );

			// No way to compare versions, do nothing.
			if ( ! is_numeric( $timestamp ) ) {
				continue;
			}

			$basename_without_timestamp = str_replace( '-' . $timestamp, '', $file->getBasename() );

			// There's a file with an older timestamp, delete it.
			if ( isset( $files_to_delete[ $basename_without_timestamp ] ) ) {
				unlink( $files_to_delete[ $basename_without_timestamp ] );
			}

			$files_to_delete[ $basename_without_timestamp ] = $file->getRealPath();
		}

		return true;
	}
public function prune() {
		if ( ! $this->enabled ) {
			return false;
		}

		/** @var Finder $finder */
		$finder = $this->get_finder()->sortByName();

		$files_to_delete = array();

		foreach ( $finder as $file ) {
			$pieces    = explode( '-', $file->getBasename( $file->getExtension() ) );
			$timestamp = end( $pieces );

			// No way to compare versions, do nothing.
			if ( ! is_numeric( $timestamp ) ) {
				continue;
			}

			$basename_without_timestamp = str_replace( '-' . $timestamp, '', $file->getBasename() );

			// There's a file with an older timestamp, delete it.
			if ( isset( $files_to_delete[ $basename_without_timestamp ] ) ) {
				unlink( $files_to_delete[ $basename_without_timestamp ] );
			}

			$files_to_delete[ $basename_without_timestamp ] = $file->getRealPath();
		}

		return true;
	}
public function prune ( ) { if ( ! $ this -> enabled ) { return false ; } /** @var Finder $finder */ $ finder = $ this -> get_finder ( ) -> sortByName ( ) ; $ files_to_delete = array ( ) ; foreach ( $ finder as $ file ) { $ pieces = explode ( '-' , $ file -> getBasename ( $ file -> getExtension ( ) ) ) ; $ timestamp = end ( $ pieces ) ; // No way to compare versions, do nothing. if ( ! is_numeric ( $ timestamp ) ) { continue ; } $ basename_without_timestamp = str_replace ( '-' . $ timestamp , '' , $ file -> getBasename ( ) ) ; // There's a file with an older timestamp, delete it. if ( isset ( $ files_to_delete [ $ basename_without_timestamp ] ) ) { unlink ( $ files_to_delete [ $ basename_without_timestamp ] ) ; } $ files_to_delete [ $ basename_without_timestamp ] = $ file -> getRealPath ( ) ; } return true ; }
Remove all cached files except for the newest version of one.

@return bool
Remove all cached files except for the newest version of one .