在控制器里
$add = array(
'id' => '',
'title' => $title,
'money' => $money,
'killmoney' => $killmoney,
'type' => $type,
'img' => $imgpath,
'time' => date('Y-m-d'),
'contact' => $contact,
'state' => 1,
'username' => $username,
'content' => $content
);
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
if ($redis->lPush("list", json_encode($add))) {
$res = $redis->lRange("list",0,2);
dump($res);
}
这样可以在在浏览器里可以打印出来。
但是在命令行里
127.0.0.1:6379> lrange list 0 2
(empty list or set)
却显示空。
这是什么情况。。
自己解决。。 key换了个名字就行了,具体原因还不清楚。