我正在使用Zend中的Cache。我开发了非常简单的应用程序,用于在缓存文件夹中存储数这是我的indexController的indexAction。
运行后,我得到Application Error
。我已在应用程序文件夹中创建了Cache文件夹数据库也在mysql中。我在开发环境中工作。我做错了什么?
public function indexAction()
{
include 'library/Zend/Cache.php';
$frontendOptions = array (
'lifetime'=> null,
'automatic_serialization' => true);
$backendOptions = array (
'cache_dir' => 'Cache/');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
$id = 'rs';
$start_time = microtime (true);
if(!($data = $cache->load($id)))
{
echo "Not found in Cache<br />";
mysql_connect ('localhost' , 'root', '');
mysql_select_db ('test');
$query = 'select * from users';
$rs = mysql_query ($query);
$data = array ();
while($row = mysql_fetch_assoc ($rs))
{
$data[] = $row;
}
$cache->save($data);
}
else
{
echo "Running from Cache<br />";
}
//echo ‘<pre>’;
//print_r($data);
//echo ‘</pre>’;
echo "sprintf ('%01.4f', microtime (true) – $start_time)";
}
我应该在公用文件夹中对application.ini和index.php进行一些更改吗??