<? php //Read article list write cache //Call method: lanye_Listcache ('1,2,3 ','20', 'listcache'); //There are three parameters. The first is the classification ID, the second is the number of reads, and the third is the cache file name function lanye_Listcache($sortid = 0, $lognum = '10', $cachename = 'listcache'){ global $CACHE; $db = Database::getInstance(); if($sortid){$query = "and sortid in ($sortid)";}else{$query = '';} $sql = "select * from ". DB_PREFIX."blog WHERE type='blog' and hide='n' and checked='y' $query ORDER BY `date` DESC LIMIT 0,$lognum"; $listcache = $CACHE->readCache($cachename); if(empty($listcache)){ $list = $db->query($sql); $listcache = array(); while($row = $db->fetch_array($list)){ $listcache[] = $row; echo '<li><a href="'. Url::log($row['gid']).' " title="'.$ row['title'].' " target="_blank">'.$row['title'].'</a></li>'; } $cacheData = serialize($listcache); $CACHE->cacheWrite($cacheData, $cachename); }else{ foreach($listcache as $row){ echo '<li><a href="'. Url::log($row['gid']).' " title="'.$ row['title'].' " target="_blank">'.$row['title'].'</a></li>'; } } }