In my project, I want to store array data into redis.
Here I use PHP.
First, It connects to redis successfully. And then I defined a array which name should be info_g_1.
Last, I use mset function to store this arry.
Here is my php code:
<?php
$redis_obj = \common\Datasource::getRedis('instance1');//connect to redis successfully
$id = '1';
$r_goods = 'info_g_' . $id;
$r_goods = array(
'sys_status' => 'one',
'num_user' => 'two'
);
$redis_obj->mset($r_goods);
But unlucky, It works fail. Thers is no info_g_1 data in my redis.
$redis_obj->sadd('info_g_'.$id,'one');
$redis_obj->sadd('info_g_'.$id,'two');
and fetch data:
$redis_obj->smembers('info_g_'.$id); //can get one and two.
But this way, I am not sure whether one belongs to sys_status or num_user.
Who can help me?