Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: clearstatcache - Manual
[go: Go Back, main page]

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

search for in the

copy" width="11" height="7"/> <chown
Last updated: Sun, 25 Nov 2007

view this page in

clearstatcache

(PHP 4, PHP 5)

clearstatcache — ファイルのステータスのキャッシュをクリアする

説明

void clearstatcache ( void )

statlstat 、 またはその他の関数(後述)を使用すると、PHPはパフォーマンス向上のために それらの関数の戻り値をキャッシュします。しかし、ケースによっては、 キャッシュされた情報を消去したい場合もあるでしょう。 例えば、一つのスクリプト上で同じファイルが何度もチェックされ、 そのファイルが変更されたり削除されたりする可能性がある場合、 ステータスキャッシュを消去しなければならないと感じるでしょう。 このようなケースでは、clearstatcache()を使用することで ファイルの情報に関してPHPが持っているキャッシュをクリアすることができます。

PHP は存在しないファイルについての情報はキャッシュしないことにも 注意してください。もし存在しないファイルに対して file_exists() をコールする場合、ファイルを作成するまで この関数は FALSE を返します。もしファイルを作成した場合、 たとえファイルを削除したとしても TRUE を返します。 しかし、unlink() はキャッシュを自動的にクリアします。

注意: この関数は特定のファイルに関する情報をキャッシュします。したがって、 同じファイルについて複数回の操作を行いそのファイルに関する情報を キャッシュされないようにするためには、 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
25-Jan-2008 05: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" width="11" height="7"/> <chown
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites