msgpack pack php,msgpack_pack和redis的诡异事
set進去redis的數據,未經過msgpack_pack之前是相同的,
從redis取出來的數據會不同
導致msgpack_unpack失敗,報502錯誤function?get_full_table(){
if(isset($this->tmp_menu_table)){
return?$this->tmp_menu_table;
}
if(!isset($this->redis)){
$this->load->library('redis',?array('connection_group'=>'default'));
}
$t?=?$this->redis->get('cache_menu_list');
//echo?strlen($t);exit;?經測試$t獲取的長度時候不同
if($t?&&?!empty($t)){
//此處會報502錯誤
$this->tmp_menu_table?=?msgpack_unpack($t);
return?$this->tmp_menu_table;
}
$this->db->order_by('order_no');
$result?=?$this->db->get($this->_table_name)->result();
$arr?=?array();
foreach?($result?as?$k=>$v)?{
$arr[$v->menu_id]?=?$v;
}
$this->redis->set('cache_menu_list',?msgpack_pack($arr));
$this->tmp_menu_table?=?$arr;
return?$arr;
}
改用serialize和unserialize未再報過502錯誤
由此可以肯定是msgpack_pack的問題
當然也可能是msgpack跟redis的兼容問題
看來雖然msgpack的壓縮雖然大些,但并不適合正式場合用途
尚未測試每次msgpack_pack的數據是否一致,晚一些測試
總結
以上是生活随笔為你收集整理的msgpack pack php,msgpack_pack和redis的诡异事的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle二阶段事物,分布式事务 两阶
- 下一篇: 刺激战场信誉分怎么刷(一提刺激消费)