select_user_index.auto_cache.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. class select_user_index_auto_cache extends auto_cache{
  3. private $key = "select:user_index:";
  4. public function load($param)
  5. {
  6. // $type = intval($param['type']);
  7. // $this->key .= $type;
  8. $this->key .= md5(serialize($param));
  9. $page=$param['page']>0?$param['page']:1;
  10. $page_size=$param['page_size']>0?$param['page_size']:20;
  11. $limit = (($page-1) * $page_size) . "," . $page_size;
  12. $key_bf = $this->key.'_bf';
  13. $list = $GLOBALS['cache']->get($this->key,true);
  14. if ($list === false) {
  15. $is_ok = $GLOBALS['cache']->set_lock($this->key);
  16. if(!$is_ok){
  17. $list = $GLOBALS['cache']->get($key_bf,true);
  18. }else{
  19. $m_config = load_auto_cache("m_config");//初始化手机端配置
  20. $has_is_authentication = intval($m_config['has_is_authentication'])?1:0;
  21. if($has_is_authentication){
  22. $sql = "SELECT u.id as user_id,u.weibo_sort_num as sort_num,u.xpoint,u.ypoint,u.show_image , u.head_image,u.thumb_head_image,u.v_type, u.v_icon, u.nick_name,u.user_level,u.city,u.create_time as user_create_time FROM
  23. ".DB_PREFIX."user u where u.is_authentication = 2 and u.mobile != '13888888888' and u.mobile != '13999999999' ";
  24. }else{
  25. $sql = "SELECT u.id as user_id,u.weibo_sort_num as sort_num, u.xpoint,u.ypoint,u.show_image , u.head_image,u.thumb_head_image,
  26. u.v_type, u.v_icon, u.nick_name,u.user_level,u.city,u.create_time as user_create_time FROM
  27. ".DB_PREFIX."user u where u.mobile != '13888888888' and u.mobile != '13999999999' ";
  28. }
  29. $sql .= " order by u.weibo_sort_num desc";
  30. $sql .= " limit " .$limit;
  31. $list = $GLOBALS['db']->getAll($sql,true,true);
  32. foreach($list as $k=>$v){
  33. //判断用户是否为今日创建的新用户,是:1,否:0
  34. if (date('Y-m-d') == date('Y-m-d',$list[$k]['user_create_time']+3600*8)){
  35. $list[$k]['today_create'] = 1;
  36. }else{
  37. $list[$k]['today_create'] = 0;
  38. }
  39. $list[$k]['head_image'] = get_spec_image($v['head_image'],150,150,1);
  40. if(empty($v['city'])){
  41. $list[$k]['city'] = '喵星';
  42. }
  43. if($v['show_image']){
  44. $show_image_num = count(unserialize($v['show_image']));
  45. }else{
  46. $show_image_num = 0;
  47. }
  48. $list[$k]['show_image_num'] = $show_image_num;
  49. }
  50. $GLOBALS['cache']->set($this->key, $list, 10, true);
  51. $GLOBALS['cache']->set($key_bf, $list, 86400, true);//备份
  52. //echo $this->key;
  53. }
  54. }
  55. if ($list == false) $list = array();
  56. return $list;
  57. }
  58. public function rm()
  59. {
  60. //$GLOBALS['cache']->clear_by_name($this->key);
  61. }
  62. public function clear_all()
  63. {
  64. //$GLOBALS['cache']->clear_by_name($this->key);
  65. }
  66. }
  67. ?>