banner_edu_list.auto_cache.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. class banner_edu_list_auto_cache extends auto_cache{
  3. private $key = "banner_edu:list:";
  4. public function load($params = array(), $is_real)
  5. {
  6. $type = $params['type'] ? intval($params['type']) : 0;
  7. $show_position = $params['show_position'] ? intval($params['show_position']) : 0;
  8. $this->key .= "{$type}_{$show_position}";
  9. $key_bf = $this->key.'_bf';
  10. $list = $GLOBALS['cache']->get($this->key,true);
  11. if ($list === false || !$is_real) {
  12. $is_ok = $GLOBALS['cache']->set_lock($this->key);
  13. if(!$is_ok){
  14. $list = $GLOBALS['cache']->get($key_bf,true);
  15. }else{
  16. $where=" 1=1 ";
  17. if(isset($params['type']))
  18. {
  19. $where .=" and type=".$params['type']."";
  20. }
  21. if(isset($params['show_position']))
  22. {
  23. $where .=" and show_position=".$show_position."";
  24. }
  25. $sql = "select id,title,image,url,type,show_id,show_position from ".DB_PREFIX."index_image where ".$where." order by sort asc";
  26. $list = $GLOBALS['db']->getAll($sql,true,true);
  27. foreach($list as $k=>$v){
  28. $list[$k]['image'] = get_spec_image($v['image']);
  29. if ($v['type'] == 8 && $v['show_id'] > 0) {
  30. //直播列表
  31. $m_config = load_auto_cache("m_config");//初始化手机端配置
  32. $sdk_version_name = strim($_REQUEST['sdk_version_name']);
  33. $dev_type = strim($_REQUEST['sdk_type']);
  34. if ($dev_type == 'ios' && $m_config['ios_check_version'] != '' && $m_config['ios_check_version'] == $sdk_version_name) {
  35. $video_list = load_auto_cache("edu_select_video_check");
  36. } else {
  37. $video_list = load_auto_cache("edu_select_video");
  38. }
  39. foreach($video_list as $kk => $vv){
  40. if(($vv['room_id'] == $v['show_id']) && $vv['is_verify'] ==0){
  41. $video=$vv;
  42. }
  43. }
  44. if($video)
  45. {
  46. $list[$k]['video'] = $video;
  47. }else{
  48. unset($list[$k]);
  49. }
  50. }
  51. }
  52. $list = array_values($list);
  53. $GLOBALS['cache']->set($this->key, $list, 3600, true);
  54. $GLOBALS['cache']->set($key_bf, $list, 86400, true);//备份
  55. //echo $this->key;
  56. }
  57. }
  58. return $list;
  59. }
  60. public function rm($param)
  61. {
  62. $GLOBALS['cache']->rm($this->key);
  63. }
  64. public function clear_all()
  65. {
  66. $GLOBALS['cache']->rm($this->key);
  67. }
  68. }
  69. ?>