cate_top.auto_cache.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. class cate_top_auto_cache extends auto_cache{
  3. private $key = "cate:top";
  4. public function load($param)
  5. {
  6. $list = $GLOBALS['cache']->get($this->key);
  7. $key_bf = $this->key.'_bf';
  8. if($list === false)
  9. {
  10. $is_ok = $GLOBALS['cache']->set_lock($this->key);
  11. if(!$is_ok){
  12. $list = $GLOBALS['cache']->get($key_bf,true);
  13. }else{
  14. $sql = "select vc.id as cate_id,vc.title,vc.num from ".DB_PREFIX."video_cate as vc
  15. where vc.is_effect = 1 order by vc.sort desc, vc.num desc limit 0,4";
  16. $list = $GLOBALS['db']->getAll($sql,true,true);
  17. foreach($list as $k=>$v){
  18. $list[$k]['title'] ="#".$v['title']."#";
  19. }
  20. $cate = array();
  21. $cate['cate_id'] = 0;
  22. $cate['title'] = '热门话题 >';
  23. $cate['num'] = 0;
  24. $list[] = $cate;
  25. $GLOBALS['cache']->set($this->key,$list,10,true);
  26. $GLOBALS['cache']->set($key_bf, $list, 86400, true);//备份
  27. }
  28. }
  29. if ($list == false) $list = array();
  30. return $list;
  31. }
  32. public function rm($param)
  33. {
  34. $GLOBALS['cache']->rm($this->key);
  35. }
  36. public function clear_all()
  37. {
  38. $GLOBALS['cache']->rm($this->key);
  39. }
  40. }
  41. ?>