sMembers方法返回NULL,这个怎么解决呢,redis 终端有值
来源:8-13 赛事直播在线用户处理 - redis方案(二)
![](http://img1.sycdn.imooc.com/user/5ba0708e0001759e09500950-100-100.jpg)
Fred68
2018-09-21
写回答
2回答
-
同学你好,你的代码截图我看看
012018-09-25 -
Fred68
提问者
2018-09-25
public function sAdd ($key, $value) { return $this->redis->sAdd($key, $value); } public function sRem ($key, $value) { return $this->redis->sRem($key, $value); } public function sMembers ($key) { return $this->redis->sMembers($key); }
Predis.php
<?php namespace app\admin\controller; use app\common\lib\Util; use app\common\lib\redis\Predis; class Live { public function push () { // print_r($_GET); // 赛况基本信息入库 数据组织好 push直播页面 // $_POST['http_server']->push(3, 'hello-chuang-push-data'); $clients = Predis::getInstance()->sMembers(config('redis.live_game_key')); var_dump($clients); } }
Live.php
// 监听ws连接事件 public function onOpen($ws,$request){ \app\common\lib\redis\Predis::getInstance()->sAdd(config('redis.live_game_key'), $request->fd); var_dump($request->fd); } // 监听ws消息事件 public function onMessage($ws,$frame){ echo "ser-push-message:{$frame->data}\n"; $ws->push($frame->fd, "server-push:".date("Y-m-d H:i:s")); } // 监听ws 关闭事件 public function onClose($ws,$fd) { \app\common\lib\redis\Predis::getInstance()->sRem(config('redis.live_game_key'), $fd); echo "clientid:{$fd}\n"; }
ws.php
之前测试步骤都显示正常,但是到sMembers这个就编程NULL,。。
00
相似问题