Prune the internal cache.

Removes all cached files except for the newest version of each one.

## EXAMPLES

$ wp cli cache prune
Success: Cache pruned.

@subcommand prune
3109
public function cache_prune() {
		$cache = WP_CLI::get_cache();

		if ( ! $cache->is_enabled() ) {
			WP_CLI::error( 'Cache directory does not exist.' );
		}

		$cache->prune();

		WP_CLI::success( 'Cache pruned.' );
	}
912367
def clear(self):
        """"""
        if self._cache is not None:
            with self._cache as c, self._out as out:
                self.in_flush_all = True
                c.clear()
                out.clear()  # pylint: disable=no-member
                self.in_flush_all = False
529593
function pruneLinks()
    {
        $this->files->ensureDirExists($this->sitesPath(), user());

        $this->files->removeBrokenLinksAt($this->sitesPath());
    }
196340
public function clear()
	{
		// Path to cache folder
		$cacheDir = PATH_APP . DS . 'cache' . DS . '*';

		// Remove recursively
		foreach (glob($cacheDir) as $cacheFileOrDir)
		{
			$readable = str_replace(PATH_APP . DS, '', $cacheFileOrDir);
			if (is_dir($cacheFileOrDir))
			{
				if (!Filesystem::deleteDirectory($cacheFileOrDir))
				{
					$this->output->addLine('Unable to delete cache directory: ' . $readable, 'error');
				}
				else
				{
					$this->output->addLine($readable . ' deleted', 'success');
				}
			}
			else
			{
				// Don't delete index.html
				if ($cacheFileOrDir != PATH_APP . DS . 'cache' . DS . 'index.html')
				{
					if (!Filesystem::delete($cacheFileOrDir))
					{
						$this->output->addLine('Unable to delete cache file: ' . $readable, 'error');
					}
					else
					{
						$this->output->addLine($readable . ' deleted', 'success');
					}
				}
			}
		}

		$this->output->addLine('Clear cache complete', 'success');
	}
801646
public function pruneAll()
    {
        $files = glob($this->config['basepath'] . '/*');
        $items = count($files);
        array_map('unlink', $files);
        return $items;
    }
668113
static function clear() {
    if ( empty(self::$_cache) || DEBUGKEEPTEMP ) return;
    
    foreach ( self::$_cache as $file ) {
      if (DEBUGPNG) print "[clear unlink $file]";
      unlink($file);
    }
  }
1231563
def prune_cache(mtime=15)
      # get old, unused entries and discard from DB and filesystem
      entries = remove_old_items(mtime)
      entries.each do |key, entry|
        FileUtils.rm_f(entry[:file])
      end
    end
1278981
private void pruneIfNeeded(int neededSpace) {
        if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes) {
            return;
        }
//        if (JusLog.DEBUG) {
//            JusLog.v("Pruning old cache entries.");
//        }
        //todo add queue markers

        long before = mTotalSize;
        int prunedFiles = 0;
        long startTime = System.nanoTime();

        Iterator<Map.Entry<String, CacheHeader>> iterator = mEntries.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, CacheHeader> entry = iterator.next();
            CacheHeader e = entry.getValue();
            boolean deleted = getFileForKey(e.key).delete();
            if (deleted) {
                mTotalSize -= e.size;
            } else {
                //todo add queue markers
//               JusLog.d("Could not delete cache entry for key=%s, filename=%s",
//                       e.key, getFilenameForKey(e.key));
            }
            iterator.remove();
            prunedFiles++;

            if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes * HYSTERESIS_FACTOR) {
                break;
            }
        }
//todo add queue markers
//        if (JusLog.DEBUG) {
//            JusLog.v("pruned %d files, %d bytes, %d ms",
//                    prunedFiles, (mTotalSize - before), System.nanoTime() - startTime);
//        }
    }
157973
public static function clearAll()
    {
        $dir = new \DirectoryIterator(static::config('directory'));

        foreach ($dir as $fileinfo) {

            if ($fileinfo->isFile()) {
                $cacheKey = $fileinfo->getFilename();
                static::clear($cacheKey);
            }
        }
    }
271132
public function clearCache()
  {
    $files = glob($this->cachePath);
    foreach($files as $file) {
      if (is_file($file)) {
        unlink($file);
      }
    }
  }
393085
private void cutCurrentCache() {

		final File lock=Configuration.getInstance().getOsmdroidTileCache();
		synchronized (lock) {

			if (mUsedCacheSpace > Configuration.getInstance().getTileFileSystemCacheTrimBytes()) {

				Log.d(IMapView.LOGTAG,"Trimming tile cache from " + mUsedCacheSpace + " to "
						+ Configuration.getInstance().getTileFileSystemCacheTrimBytes());

				final List<File> z = getDirectoryFileList(Configuration.getInstance().getOsmdroidTileCache());

				// order list by files day created from old to new
				final File[] files = z.toArray(new File[0]);
				Arrays.sort(files, new Comparator<File>() {
					@Override
					public int compare(final File f1, final File f2) {
						return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
					}
				});

				for (final File file : files) {
					if (mUsedCacheSpace <= Configuration.getInstance().getTileFileSystemCacheTrimBytes()) {
						break;
					}

					final long length = file.length();
					if (file.delete()) {
						if (Configuration.getInstance().isDebugTileProviders()){
							Log.d(IMapView.LOGTAG,"Cache trim deleting " + file.getAbsolutePath());
						}
						mUsedCacheSpace -= length;
					}
				}

				Log.d(IMapView.LOGTAG,"Finished trimming tile cache");
			}
		}
	}
598064
static function clear_cache() {
			self::_init();

			self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
			self::$_cache->clear();
		}
152853
private void pruneIfNeeded(int neededSpace) {
        if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes) {
            return;
        }
        if (VolleyLog.DEBUG) {
            VolleyLog.v("Pruning old cache entries.");
        }

        long before = mTotalSize;
        int prunedFiles = 0;
        long startTime = System.currentTimeMillis();

        Iterator<Map.Entry<String, CacheHeader>> iterator = mEntries.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, CacheHeader> entry = iterator.next();
            CacheHeader e = entry.getValue();
            boolean deleted = getFileForKey(e.key).delete();
            if (deleted) {
                mTotalSize -= e.size;
            } else {
               VolleyLog.d("Could not delete cache entry for key=%s, filename=%s",
                       e.key, getFilenameForKey(e.key));
            }
            iterator.remove();
            prunedFiles++;

            if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes * HYSTERESIS_FACTOR) {
                break;
            }
        }

        if (VolleyLog.DEBUG) {
            VolleyLog.v("pruned %d files, %d bytes, %d ms",
                    prunedFiles, (mTotalSize - before), System.currentTimeMillis() - startTime);
        }
    }
1352261
def clear(self):
        
        self.log(u"Clearing cache...")
        for file_handler, file_info in self.cache.values():
            self.log([u"  Removing file '%s'", file_info])
            gf.delete_file(file_handler, file_info)
        self._initialize_cache()
        self.log(u"Clearing cache... done")
626230
public function clear()
    {
        $cachePath   = $this->options['path'];
        $cachePrefix = $this->options['prefix'] ? $this->options['prefix'].DIRECTORY_SEPARATOR : '';
        $files       = (array) glob($cachePath.$cachePrefix.'*');

        foreach ($files as $file) {
            if (is_dir($file)) {
                $matches = glob($file.'/*.php');
                if (is_array($matches)) {
                    array_map('unlink', $matches);
                }
                rmdir($file);
            } else {
                $this->unlink($file);
            }
        }

        return true;
    }
95749
public function clearCache()
	{
	    $path = $this->getCompiledPath();
	    if (is_dir($path)) {
	        return Dir::delete($path);
	    }
	    return true;
	}
310257
def clean_caches(path):
    

    for dirname, subdirlist, filelist in os.walk(path):

        for f in filelist:
            if f.endswith('pyc'):
                try:
                    os.remove(os.path.join(dirname, f))
                except FileNotFoundError:
                    pass

        if dirname.endswith('__pycache__'):
            shutil.rmtree(dirname)