PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

copy> <chown
Last updated: Fri, 16 May 2008

view this page in

clearstatcache

(PHP 4, PHP 5)

clearstatcache — Очищает кэш состояния файлов

Описание

void clearstatcache ( void )

Когда вы используете функции stat(), lstat() или любую из функций, перечисленных в приведенном ниже списке, PHP кеширует результаты их выполнения для обеспечения большей производительности. Однако, в некоторых случаях вам может потребоваться очистка этого кэша. Например, когда ваш скрипт несколько раз проверяет состояние одного и того же файла, который может быть изменен или удален во время выполнения скрипта.

Обратите внимание, что PHP не кэширует информацию о несуществующих файлах. Так что если вы вызовите file_exists() на несуществующем файле, она будет возвращать FALSE до тех пор, пока вы не создадите этот файл. Если же вы создадите файл, она будет возвращать TRUE даже если затем вы его удалите.

Замечание: Результаты выполнения приведенных ниже функций кешируются PHP, поэтому, если вы не хотите, чтобы информация о файле или каталоге, с которым вы работаете, кешировалась, используйте функцию clearstatcache().

Список функций, результаты выполнения которых кешируются: stat(), lstat(), file_exists(), is_writable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype() и fileperms().



add a note add a note User Contributed Notes
clearstatcache
stangelanda at gmail dot com
24-Jan-2008 12:35
It should be noted that a call to any of those functions will cache all of the file's information, not just the information that is returned.

Obviously it is clear that the following requires you to clear the cache.
<?php
    $size1
= filesize($filename);
   
unlink($filename);   
   
$size2 = filesize($filename);
   
// $size2 still equals $size1, unless you cleared the stat cache in between.
?>

<?php
    $access
= fileatime($filename);
   
unlink($filename);   
   
$size = filesize($filename);
   
// $size will be the filesize before it was unlinked, because the filesize was cached when fileatime was called, even though the two functions wouldn't appear to have anything to do with either other.
?>

Confirmed on a windows system.

copy> <chown
Last updated: Fri, 16 May 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites