php new redis报错,直接在Gateway.php写代码使用redis,报错

/**

* This file is part of workerman.

*

* Licensed under The MIT License

* For full copyright and license information, please see the MIT-LICENSE.txt

* Redistributions of files must retain the above copyright notice.

*

* @author walkor

* @copyright walkor

* @link http://www.workerman.net/

* @license http://www.opensource.org/licenses/mit-license.php MIT License

*/

namespace GatewayWorker\Lib;

use Exception;

use GatewayWorker\Protocols\GatewayProtocol;

use Workerman\Connection\TcpConnection;

/**

* 数据发送相关

*/

class Gateway

{

private $redis;

public $checkUserReadable = false;

public static function setChatRecord($from, $to, $message) {

$data = array('from' => $from, 'to' => $to, 'message' => $message, 'sent' => time());

$value = json_encode($data);

//生成json字符串

$keyName = 'rec:' . self::getRecKeyName($from, $to);

$redis = new Redis();

$redis->connect('127.0.0.1', 6379);

$res = $redis -> lPush($keyName, $value);

if (!$this -> checkUserReadable) {//消息接受者无法立刻查看时,将消息设置为未读

return $redis -> hIncrBy('unread_' . $to, $from, 1);

}

return $res;

}

private static function getRecKeyName($from, $to)

{ if ($from > $to){return $to . '_' . $from;

}else{ return $from . '_' . $to;}

}

/**

* gateway 实例

*/

报错信息

Fatal error: Class 'GatewayWorker\Lib\Redis' not found in /pi/components/com_work/GatewayWorker/Lib/Gateway.php on line 49

WORKER EXIT UNEXPECTED E_ERROR Class 'GatewayWorker\Lib\Redis' not found in /pi/components/com_work/GatewayWorker/Lib/Gateway.php on line 49

worker exit with status 65280

49行就是$redis = new Redis(); 是不是不能直接使用redis.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值