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?
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.