prop_id.auto_cache.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. class prop_id_auto_cache extends auto_cache{
  3. public function load($param)
  4. {
  5. $id = intval($param['id']);
  6. $key = "prop:".$id;
  7. $prop = $GLOBALS['cache']->get($key);
  8. if($prop === false)
  9. {
  10. $sql = "select id,name,score,diamonds,icon,pc_icon,pc_gif,ticket,is_much,sort,is_red_envelope,is_animated,anim_type,robot_diamonds from ".DB_PREFIX."prop where id=".$id;
  11. $prop = $GLOBALS['db']->getRow($sql,true,true);//以后需要缓存
  12. $prop['icon'] = get_spec_image($prop['icon']);
  13. if ($prop['is_animated'] == 1){
  14. //要缓存getAllCached
  15. $sql = "select id,url,play_count,delay_time,duration,show_user,type from ".DB_PREFIX."prop_animated where prop_id = ".$id." order by sort desc";
  16. $anim_list = $GLOBALS['db']->getAll($sql,true,true);
  17. foreach ( $anim_list as $k => $v )
  18. {
  19. $anim_list[$k]['url'] = get_spec_image($v['url']);
  20. }
  21. $prop['anim_cfg'] = $anim_list;
  22. //$ext['sql'] = $sql;
  23. }else{
  24. $prop['anim_cfg'] = array();
  25. }
  26. $GLOBALS['cache']->set($key,$prop);
  27. }else{
  28. //echo 'cache';
  29. }
  30. return $prop;
  31. }
  32. public function rm($param)
  33. {
  34. $id = intval($param['id']);
  35. $key = "prop:".$id;
  36. $GLOBALS['cache']->rm($key);
  37. }
  38. public function clear_all($param)
  39. {
  40. $id = intval($param['id']);
  41. $key = "prop:".$id;
  42. $GLOBALS['cache']->rm($key);
  43. }
  44. }
  45. ?>