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, 11 Apr 2008

view this page in

clearstatcache

(PHP 4, PHP 5)

clearstatcache — Limpia la cache de estado de un archivo

Descripción

void clearstatcache ( void )

Cuando se usa stat(), lstat(), o cualquier otra de las funciones en la lista de funciones afectadas (vea abajo), PHP pone en cache la información de lo que devuelven esas funciones, en aras de proveer mayor desempeño. Sin embargo, en ciertos casos, tal vez desee quitar la información en el cache. Por ejemplo, si el mismo archivo está siendo revisado muchas veces dentro de un mismo script, y ese archivo está en peligro de ser removido o cambia durante la operación del script, puede escoger borrar el cache. En estos casos, puede usar la función clearstatcache() para limpiar la información que PHP pone en cache acerca del archivo.

Debe notar también que PHP no pone información en cache de archivos que no existen. De tal manera, que si ejecuta file_exists() en un archivo que no existe, regresará FALSE hasta que cree el archivo. SI crea el archivo, regresará TRUE aunque haya borrado el archivo.

Note: Esta función pone en cache información acerca de nombres de archivo especificos, de tal forma que solo necesita ejecutar clearstatcache() si está elaborando operaciones múltiples sobre el mismo archivo y necesita que la información sobre un archivo en particular no se ponga en cache.

Entre las funciones afectadas se incluyen stat(), lstat(), file_exists(), is_writeable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype(), y 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, 11 Apr 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites