Sign in
Log inSign up
Which one is better in Redis (predis) - To have one SET with array encoded in JSON or have many sets but without encoding?

Which one is better in Redis (predis) - To have one SET with array encoded in JSON or have many sets but without encoding?

Vytautas Sakalauskas's photo
Vytautas Sakalauskas
·Apr 7, 2016

Which way is better? For example:

function saveMessages()
{

$array = array(

    'message' =>  "My message",
    'to_send' => 2,
    'from_send' => 1,                            
    'create_time' => date('Y-m-d H:i:s')
);

$encode_message =json_encode($array);

$redis->SET("messages",$encode_message);

$getMessages = $redis ->GET("messages");
$decodeMessages = json_decode($getMessages,true);

return   $decodeMessages;

}

P.S sorry for my EN.