//$cache->write(1,$time2); //只缓存$time部分的数据
// 在浏览器里输入http://localhost/test/ztest.php 可能会有错但不用担心
// 运行结果: Notice: Undefined index: cacheact in D:\wamp_php\wamp\www\test\ztest.php on line 11 Strict Standards: mktime(): You should be using the time() function instead in D:\wamp_php\wamp\www\test\cache.php on line 20
第一个缓存字符串:13:51:00 20th April
第二个缓存字符串:13:51:00 20th April
更新
// 生成的缓存文件是:
cache\003d47a2f66c6d7f0f05a18243ca162c.Php
/* 第一个缓存字符串:13:31:26 20th April<br/>第二个缓存字符串:13:31:26 20th April<br/><a href="?cacheact=rewrite">更新</a> */
cache\834bf560e67a566ef08efa0df269894e.Php
/* 第一个缓存字符串:13:51:00 20th April<br/>第二个缓存字符串:13:51:00 20th April<br/><a href="?cacheact=rewrite">更新</a> */
// 这里报了两个错误 ,点击链接 更新 (http://localhost/test/ztest.php?cacheact=rewrite) ,错误是因为你没有传入参数 cacheact ,点击 更新 链接 就不会报错了;
当你更改 test.php 里的$time和$time2的内容的时候 点击 更新链接 cache\003d47a2f66c6d7f0f05a18243ca162c.Php缓存的文件内容会更新成你更改后的内容 但是 cache\834bf560e67a566ef08efa0df269894e.Php的内容却还是原来的没有被改变。
这个问题你来回答吧
// 这个函数就是自己写的那个缓存应用(thinkphp框架下写的)
public function choicedatedata($choiceTime){
$cacheName = 'laterdatedata_'.$choiceTime; // laterdatedata_2014-03-16
$ret = cache($cacheName);
if(!$ret){
$sql = "select count(0) as a from edl_login_game_log where DATE_FORMAT(CreateTime,'%Y-%m-%d') = '".$choiceTime."' and Username not in (select UserName from edl_login_game_log where DATE_FORMAT(CreateTime,'%Y-%m-%d')< '".$choiceTime."' group by UserName) group by UserName";
$ret = $this->query($sql);
cache($cacheName,$ret);
}
return $ret;
}