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: Sun, 25 Nov 2007

view this page in

clearstatcache

(PHP 4, PHP 5)

clearstatcache — 파일의 통계(stat) 캐시를 삭제합니다.

Description

void clearstatcache ( void )

대부분의 운영체제에서statlstat 등의 시스템호출을 사용해서 일을하는 것은 꽤 자원을 많이 소모합니다. 그렇기 때문에 최종적으로 사용된 상태를 나타내는 함수(아래에 나열된)의 결과는 다음번에 같은 파일이름을 사용하여 그런 호출을 할 경우를 위하여 저장이 됩니다. 만약에 파일이 여러번 체크가 되었고 파일이 바뀌거나 파일이 없어졌을 경우등에 상태를 강제로 다시 체크하고자 한다면 이 함수를 사용하여 저장되어있는 최종결과를 메모리에서 삭제할 수 있습니다.

이 값은 어떤 단일 요청(request)이 유효할 때까지만 캐시된 값입니다.

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()이 이 함수의 영향을 받게 되는 함수입니다.



copy> <chown
Last updated: Sun, 25 Nov 2007
 
add a note add a note User Contributed Notes
clearstatcache
Anonymous
26-Sep-2008 05:49
re stangelanda at gmail dot com
I have tested this on Windows XP SP3, PHP Version 5.2.5 and I got a warning:

filesize() stat failed for $filename on the second call to the filesize() function

ie it worked as I would expect so unless the bug has been introduced since then - no bug.
BlueCamel
06-Aug-2008 06:58
Regarding the previous user note, the docs say that calling unlink() for a file will clear any stats cache for that file. If you're seeing the described windows behavior it sounds like a possible PHP bug or doc bug.
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: Sun, 25 Nov 2007
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites