<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[PHP filesize() 函数是有缓存的，你需要清除文件状态缓存。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Thu, 17 Dec 2015 11:01:36 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：有时有做一些H5的websocket做模仿linux下的tail -f，形成一个实时日志查看工具时，会对写入事件前的文件大小和写入事件后的文件大小作一个计算，而在实际调试时发现这个PHP的filessize函数是有缓存的，这个链接的兄弟在问怎么破？（http://segmentfault.com/q/1010000003843245），如下文所示 。<br/><br/>定义和用法<br/>clearstatcache()函数的作用是：清除文件状态缓存。<br/>PHP的缓存数据对更快更好的运行函数是非常有利的。如果一个文件在脚本中测试了多次，你也许会禁止对正确的结果进行缓存。为了实现这点，你可以使用clearstatcache()函数。<br/>语法<br/>clearstatcache()<br/>提示和注意<br/>提示：执行缓存的函数：<br/>stat() <br/>lstat() <br/>file_exists() <br/>is_writable() <br/>is_readable() <br/>is_executable() <br/>is_file() <br/>is_dir() <br/>is_link() <br/>filectime() <br/>fileatime() <br/>filemtime() <br/>fileinode() <br/>filegroup() <br/>fileowner() <br/>filesize() <br/>filetype() <br/>fileperms()<br/><br/>案例<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php 
//check filesize 
echo filesize(&quot;test.txt&quot;); 
echo &quot;&lt;br /&gt;&quot;; 
$file = fopen(&quot;test.txt&quot;, &quot;a+&quot;); 
// truncate file 
ftruncate($file,100); 
fclose($file);//Clear cache and check filesize againcle 
clearstatcache(); 
echo filesize(&quot;test.txt&quot;); 
?&gt;
</textarea><br/>上述代码将输出下面的结果：<br/>事件前文件大小：59635<br/>事件后文件大小：59639<br/><br/>来自：http://www.chinaz.com/program/2010/0302/107501.shtml
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] PHP filesize() 函数是有缓存的，你需要清除文件状态缓存。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>