banner_list_xr.auto_cache.php 1.6 KB

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