|
clearstatcacheClears file status cache Description
void clearstatcache(bool
$clear_realpath_cache = false, string $filename = "")When you use stat, lstat, or any of the other functions listed in the affected functions list (below), PHP caches the information those functions return in order to provide faster performance. However, in certain cases, you may want to clear the cached information. For instance, if the same file is being checked multiple times within a single script, and that file is in danger of being removed or changed during that script's operation, you may elect to clear the status cache. In these cases, you can use the clearstatcache function to clear the information that PHP caches about a file.
You should also note that PHP doesn't cache information about non-existent
files. So, if you call is_file on a file that
doesn't exist, it will return
Affected functions include stat, lstat, file_exists, is_writable, is_readable, is_executable, is_file, is_dir, is_link, filectime, fileatime, filemtime, fileinode, filegroup, fileowner, filesize, filetype, and fileperms. file_exists, is_writable, is_readable and is_executable only use the cache for paths that use a wrapper other than the local filesystem. Local files are checked directly every time. Parameters
Return ValuesNo value is returned. Examples
Example #1 clearstatcache example The above example will output something similar to:
Run this command in another shell:
echo " World!" >> /tmp/stat-demo-6fjvs4vir9ll2haCl4W
Before: 5
Cached: 5
Fresh: 13
|