douqian1975 2013-11-18 15:22
浏览 205
已采纳

predis hmset嵌套数组的值

I am using predis php client. My code is like:

$ObjArray = get_object_vars ( $obj );     
$redis->hmset("post:4545",$objArray);

ObjArray is like: array( "id" => 1212, "name" => "test", "likes" => array(1,2,3), "comments" => array(0=>(1,2,3),1=>(1,2,3))

With this I get the error: redis ERR Protocol error: invalid bulk length

Can't we have array in value of redis hashe?

  • 写回答

3条回答 默认 最新

  • drd0833 2013-11-20 10:33
    关注

    Redis hashes are not multidimensional so field values can only be strings. The values in likes and comments in your $ObjArray variable are arrays which means they are not good, you should either serialize them (JSON or whichever serialization format you prefer) or store them into different and separate keys.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏