Maison >développement back-end >tutoriel php >PHP有关问题(急)
PHP问题(急)
请各位高手帮忙:下面的缓存代码:怎么样实现每隔15分钟就调用一次钻石榜,魅力榜,职分榜:
//调用缓存
$cacheM = new Seed_Model_Cache2File();
$money_list = $cacheM->get("money_list");
$extcredits2_list = $cacheM->get("extcredits2_list");
$extcredits1_list = $cacheM->get("extcredits1_list");
if (!isset($money_list)){
//钻石榜
$userM = new User_Model_User('user');
$money_list = $userM->fetch_rows(array(0,7), $where_str, array('money desc'));
//echo 111;//测试是否在用缓存;
$cacheM->save("money_list",$money_list);
}
if (!isset($extcredits2_list)){
//魅力榜
$bbsM = new User_Model_Bbs('bbs');
$extcredits2_list = $bbsM->fetch_rows(array(0,7),$where_str,"extcredits2 DESC");
$cacheM->save("extcredits2_list",$extcredits2_list);
}
if (!isset($extcredits1_list)){
//职分榜
$extcredits1_list = $bbsM->fetch_rows(array(0,7),$where_str,"extcredits1 DESC");
$cacheM->save("extcredits1_list",$extcredits1_list);
}
$this->view->money_list = $money_list;
$this->view->extcredits2_list = $extcredits2_list;
$this->view->extcredits1_list = $extcredits1_list;
------解决方案--------------------
使用系统的任务计划。要不就写个死循环;sleep(15*60)shell调用。