Predis不保存JSON字符串的部分内容

Predis不保存JSON字符串的部分内容,json,redis,predis,Json,Redis,Predis,我正试图使用Predis库将Cakephp中$u会话的JSON表示(JSON_encode)保存到Redis中 以下是$\u会话原始数据: { ["Config"]=> array(3) { ["userAgent"]=> string(32) "ebbd08f362083e95a8eb3bd1d4712648" ["time"]=> int(1368391599) ["countdown"]=> int(10) } ["Auth"]=> array(1) { ["

我正试图使用Predis库将Cakephp中$u会话的JSON表示(JSON_encode)保存到Redis中

以下是$\u会话原始数据:

{ ["Config"]=> array(3) { ["userAgent"]=> string(32) "ebbd08f362083e95a8eb3bd1d4712648" ["time"]=> int(1368391599) ["countdown"]=> int(10) } ["Auth"]=> array(1) { ["User"]=> array(24) { ["id"]=> string(2) "93" ["user_group_id"]=> string(1) "1" ["first_name"]=> string(5) "James" ["about"]=> NULL ["phone"]=> NULL ["img_path"]=> string(28) "93_1368161032_1368161032.jpg" ["score"]=> string(4) "0.00" ["active"]=> string(1) "0" ["created"]=> NULL ["modified"]=> string(19) "2013-03-13 04:14:36" ["fbid"]=> string(1) "0" ["twid"]=> NULL ["location"]=> string(0) "" ["hometown"]=> string(0) "" ["iteneraries"]=> string(1) "2" ["place_visited"]=> string(1) "0" ["reviews"]=> string(1) "0" ["isName"]=> bool(false) ["isAddress"]=> bool(false) ["invite_code"]=> string(7) "SK47SLE" } } }  
json_解码后:

{"Config":{"userAgent":"ebbd08f362083e95a8eb3bd1d4712648","time":1368391599,"countdown":10},"Auth":{"User":{"id":"93","user_group_id":"1","first_name":"James","about":null,"phone":null,"img_path":"93_1368161032_1368161032.jpg","score":"0.00","active":"0","created":null,"modified":"2013-03-13 04:14:36","fbid":"0","twid":null,"location":"","hometown":"","iteneraries":"2","place_visited":"0","reviews":"0","isName":false,"isAddress":false,"invite_code":"SK47SLE"}}}
与redis相关的代码设置值:

public function write($id, $data) {
    $tmp = $_SESSION;
    session_decode($data);

    $tmp_data = json_encode($_SESSION);
    $_SESSION = $tmp;
    $this->_client->set($id, $tmp_data);
}
调用set后在redis上检查时,仅保存以下部分:

 {"Config":{"userAgent":"ebbd08f362083e95a8eb3bd1d4712648","time":1368391599,"countdown":10}}

其余JSON数据被切断/未保存到redis。这可能有什么问题?在将JSON设置为redis的过程中,我是否遗漏了什么。

尝试保存您发布的字符串文字,而不是从会话中获取,只是硬编码。那么这会发生吗?从命令行(
redis cli
)执行此操作时是否会发生这种情况?从密钥读取的代码是否正确?@akonsu在redis-cli中硬编码json字符串时工作正常。在程序中写入硬编码字符串时会发生什么情况?如果我硬编码字符串,则会正确保存。