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, 04 Jul 2008

view this page in

clearstatcache

(PHP 4, PHP 5)

clearstatcache — Löscht den Status Cache

Beschreibung

void clearstatcache ( void )

Wenn Sie stat , lstat oder eine andere in der nachstehenden Liste der betroffenen Funktionen verwenden, speichert (cached) PHP die von diesen Funktionen zurückgeggebenen Informationen temporär, um eine bessere Performance zu bieten. In manchen Fällen könnten Sie jedoch wollen, dass diese zwischengespeicherten Informationen gelöscht werden. Wird z.B. die selbe Datei innerhalb eines Skriptes mehrmals geprüft und ist es wahrscheinlich, dass diese Datei während der Ausführung des Skriptes gelöscht oder verändert wird, könnten Sie sich dafür entscheiden, den Status Cache zu löschen. In solchen Fällen empfiehlt es sich, die von PHP zwischengespeicherten Informationen über eine Datei mittels clearstatcache() zu löschen.

Hinweis: Diese Funktion speichert Informationen über bestimmte Dateinamen, weshalb Sie clearstatcache() nur aufrufen müssen, wenn Sie mehrere Operationen an dem selben Dateinamen durchführen, und die Informationen über genau diese Datei nicht gespeichert werden sollen.

Folgende Funktionen betreffen den Dateistatus: stat(), lstat(), file_exists(), is_writable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype() und fileperms().



add a note add a note User Contributed Notes
clearstatcache
stangelanda at gmail dot com
24-Jan-2008 09: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, 04 Jul 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites