insert($data); } } /** * 更新Rpc * @param mixed $data 数据 * @param mixed $rpc_id ID * @param mixed $type type * @return mixed 返回值 */ public function updateRpc($data,$rpc_id,$type='request') { list($id,$calltime) = explode('-', $rpc_id); $cache_key = sprintf("rpcpoll-%s-%s",$type,$rpc_id); $rpc_res_info = cachecore::fetch($cache_key); if ($rpc_res_info === false) { $filter = array('id'=>$id,'type'=>$type); if ($calltime) $filter['calltime'] = $calltime; $this->update($data,$filter); } else { $rpc_res_info = unserialize($rpc_res_info); $rpc_res_info = is_array($rpc_res_info) ? $rpc_res_info : []; $rpc_res_info = array_merge($rpc_res_info,$data); cachecore::store($cache_key,serialize($rpc_res_info),10800); } } /** * 删除Rpc * @param mixed $rpc_id ID * @param mixed $type type * @return mixed 返回值 */ public function deleteRpc($rpc_id,$type='request') { list($id,$calltime) = explode('-', $rpc_id); $cache_key = sprintf("rpcpoll-%s-%s",$type,$rpc_id); $rpc_res_info = cachecore::fetch($cache_key); if($rpc_res_info === false){ $filter = array('id'=>$id,'type'=>$type); if ($calltime) $filter['calltime'] = $calltime; $this->delete($filter); }else{ cachecore::store($cache_key,'',1); } } /** * 获取Rpc * @param mixed $rpc_id ID * @param mixed $type type * @return mixed 返回结果 */ public function getRpc($rpc_id,$type='request') { list($id,$calltime) = explode('-', $rpc_id); $cache_key = sprintf("rpcpoll-%s-%s",$type,$rpc_id); $rpc_res_info = cachecore::fetch($cache_key); if($rpc_res_info === false){ $filter = array('id'=>$id,'type'=>$type); if ($calltime) $filter['calltime'] = $calltime; $tmp = $this->getList('*', $filter,0,1); }else{ $rpc_res_info = unserialize($rpc_res_info); $rpc_res_info['params'] = unserialize($rpc_res_info['params']); $tmp = array(0=>$rpc_res_info); } return $tmp; } private function _use_memcache() { return true; } }