msgpack pack php,msgpack_pack和redis的诡异事
set進(jìn)去redis的數(shù)據(jù),未經(jīng)過(guò)msgpack_pack之前是相同的,
從redis取出來(lái)的數(shù)據(jù)會(huì)不同
導(dǎo)致msgpack_unpack失敗,報(bào)502錯(cuò)誤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;?經(jīng)測(cè)試$t獲取的長(zhǎng)度時(shí)候不同
if($t?&&?!empty($t)){
//此處會(huì)報(bào)502錯(cuò)誤
$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未再報(bào)過(guò)502錯(cuò)誤
由此可以肯定是msgpack_pack的問(wèn)題
當(dāng)然也可能是msgpack跟redis的兼容問(wèn)題
看來(lái)雖然msgpack的壓縮雖然大些,但并不適合正式場(chǎng)合用途
尚未測(cè)試每次msgpack_pack的數(shù)據(jù)是否一致,晚一些測(cè)試
總結(jié)
以上是生活随笔為你收集整理的msgpack pack php,msgpack_pack和redis的诡异事的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: oracle二阶段事物,分布式事务 两阶
- 下一篇: ajax从php里能输出俩值,Ajax返