banner_list.auto_cache.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class banner_list_auto_cache extends auto_cache{
  3. private $key = "banner:list";
  4. public function load($param)
  5. {
  6. $key_bf = $this->key.'_bf';
  7. $list = $GLOBALS['cache']->get($this->key,true);
  8. if ($list === false) {
  9. $is_ok = $GLOBALS['cache']->set_lock($this->key);
  10. if(!$is_ok){
  11. $list = $GLOBALS['cache']->get($key_bf,true);
  12. }else{
  13. $sql = "select title,image,url,type,show_id from ".DB_PREFIX."index_image where show_position not in(3,4,5,6,7,8,9) order by sort asc";
  14. $list = $GLOBALS['db']->getAll($sql,true,true);
  15. foreach($list as $k=>$v){
  16. $list[$k]['type'] = $v['type'];
  17. $list[$k]['show_id'] = $v['show_id'];
  18. $list[$k]['url'] = $v['url'];
  19. $list[$k]['title'] = $v['title'];
  20. $list[$k]['image_width'] = 828;
  21. $list[$k]['image_height'] = 240;//
  22. $list[$k]['image'] = get_spec_image($v['image']);
  23. }
  24. $GLOBALS['cache']->set($this->key, $list, 3600, true);
  25. $GLOBALS['cache']->set($key_bf, $list, 86400, true);//备份
  26. //echo $this->key;
  27. }
  28. }
  29. return $list;
  30. }
  31. public function rm($param)
  32. {
  33. $GLOBALS['cache']->rm($this->key);
  34. }
  35. public function clear_all()
  36. {
  37. $GLOBALS['cache']->rm($this->key);
  38. }
  39. }
  40. ?>