playback_list.auto_cache.php 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. class playback_list_auto_cache extends auto_cache{
  3. private $key = "playback:list:user_id:";
  4. public function load($param)
  5. {
  6. $user_id = intval($param['user_id']);
  7. $this->key .= $user_id;
  8. $playback = $GLOBALS['cache']->get($this->key,true);
  9. if($playback === false)
  10. {
  11. $playback = array();
  12. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  13. $userfollw_redis = new UserFollwRedisService($user_id);
  14. $focus_user = $userfollw_redis->get_follonging_user($user_id,0,100);
  15. if(sizeof($focus_user)){
  16. $psql = '';
  17. foreach($focus_user as $k=>$v){
  18. if($psql){
  19. $psql.=',';
  20. }
  21. $psql.=$v['user_id'];
  22. }
  23. //精彩回放(只列出当天结束的回放)
  24. $sql = "select v.id as room_id,v.group_id,v.user_id,v.city,v.title,v.end_time,v.begin_time,v.max_watch_number,v.video_vid,
  25. u.nick_name,u.head_image,u.thumb_head_image,u.v_type,u.v_icon from ".DB_PREFIX."video_history as v
  26. left join ".DB_PREFIX."user as u on v.user_id=u.id
  27. where v.is_live_pay = 0 and v.is_delete = 0 and v.is_del_vod = 0 and v.user_id=u.id and v.end_date =' ".to_date(NOW_TIME,'Y-m-d')."' and v.user_id in (".$psql.") order by v.begin_time desc limit 0,30";
  28. // $list = $GLOBALS['db']->getAll("select v.id as room_id,v.group_id as group_id,(v.watch_number + v.robot_num + v.virtual_watch_number) as watch_number,v.video_vid,v.room_type,v.vote_number,v.create_time,u.id as user_id,u.nick_name as nick_name,u.head_image as head_image,u.thumb_head_image,u.user_level as user_level,u.sex as sex,u.province as province,u.city as city from ".DB_PREFIX."focus as f left join ".DB_PREFIX."user as u on f.podcast_id=u.id left join ".DB_PREFIX."video as v on v.user_id = f.podcast_id where f.user_id = ".$user_id." and v.is_playback =1 and v.live_in = 0 and ".time()."-v.create_time<86400 and v.begin_time <> 0 order by v.create_time desc");
  29. /*$sql = "select v.id as room_id,v.group_id,v.user_id,v.city,v.title,v.end_time,v.begin_time,v.max_watch_number,
  30. u.nick_name,u.head_image,u.thumb_head_image,u.v_type,u.v_icon from ".DB_PREFIX."video_history as v
  31. left join ".DB_PREFIX."user as u on v.user_id=u.id
  32. where v.is_delete = 0 and v.is_del_vod = 0 and v.user_id=u.id order by watch_number desc limit 0,30";*/
  33. $playback = $GLOBALS['db']->getAll($sql,true,true);
  34. foreach ( $playback as $k => $v )
  35. {
  36. $max_watch_number = intval($v['max_watch_number']);
  37. //$playback[$k]['is_cache'] = 1;
  38. $playback[$k]['playback_time'] = get_time_len($v['begin_time'],$v['end_time']);
  39. $playback[$k]['begin_time_format'] = format_show_date($v['begin_time']);
  40. $playback[$k]['head_image'] = get_spec_image($v['head_image']);
  41. $playback[$k]['thumb_head_image'] = get_spec_image($v['thumb_head_image']);
  42. if ($max_watch_number > 10000){
  43. $playback[$k]['watch_number_format'] = round($max_watch_number/10000,2)."万";
  44. }else{
  45. $playback[$k]['watch_number_format'] = $max_watch_number;
  46. }
  47. $playback[$k]['max_watch_number'] = $max_watch_number;
  48. if ($v['title'] == '')
  49. $playback[$k]['title'] = "....";
  50. $playback[$k]['nick_name'] = $v['nick_name']?$v['nick_name']:'';
  51. $playback[$k]['nick_name'] = htmlspecialchars_decode($v['nick_name']);
  52. $playback[$k]['signature'] = $v['signature']?$v['signature']:'';
  53. $playback[$k]['signature'] = htmlspecialchars_decode($v['signature']);
  54. }
  55. }
  56. $GLOBALS['cache']->set($this->key, $playback, 60,true);
  57. }
  58. return $playback;
  59. }
  60. public function rm($param)
  61. {
  62. //$GLOBALS['cache']->rm($this->key);
  63. $id = intval($param['user_id']);
  64. $this->key .= $id;
  65. $GLOBALS['cache']->rm($this->key);
  66. }
  67. public function clear_all($param)
  68. {
  69. //$GLOBALS['cache']->rm($this->key);
  70. $id = intval($param['user_id']);
  71. $this->key .= $id;
  72. $GLOBALS['cache']->rm($this->key);
  73. }
  74. }
  75. ?>