我正在尝试使用http://www.phpfastcache.com/在页面上缓存查询。
我在页面上没有错误,文件正在成功地创建在它需要的cached.storage文件夹中,但是当我在查询中更改数据时,它并不是在缓存数据。我做错了什么?
include_once("php_fast_cache.php");
phpFastCache::$storage = "auto";
$getItemsQuery = phpFastCache::get("$itemId");
if($getItemsQuery == null) {
$getItemsQuery = mysql_query("select item_id, item_name from items where item_id = $itemId");
phpFastCache::set("$itemId", $getItemsQuery,86400);
}发布于 2013-11-08 20:27:57
啊,没错,你应该在缓存中缓存实际的“数据”( data,您从mysql_fetch_assoc等获得的数据)。
尝试缓存从运行查询中得到的“资源”不会有帮助,因为下一个调用' get‘的实例将无法使用该资源(即使它是缓存的--我对此表示怀疑)。
..。您没有看到错误,因为'get‘失败了,所以只运行mysql查询。
这里可以忽略使用mysql扩展的问题。使用mysqli或PDO等将有完全相同的问题使用这种方式。
https://stackoverflow.com/questions/19865124
复制相似问题