I want to delete cache files in a directory, a directory can contain up to 50,000 files. I am currently using this feature.
// Deletes all files in $type directory that start with $start function clearCache($type,$start) { $open = opendir($GLOBALS['DOC_ROOT']."/cache/".$type."/"); while( ($file = readdir($open)) !== false ) { if ( strpos($file, $start)!==false ) { unlink($GLOBALS['DOC_ROOT']."/cache/".$type."/".$file); } } closedir($open); }
This works fine and it's fast, but is there a faster way to do this? (scan_dir seems slow). I can explicitly move the cache to memory.
Thank you, Village
source share