swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 788 forks source link

[redis]协程redis has 方法报错 #189

Closed aprchen closed 6 years ago

aprchen commented 6 years ago
Q A
Bug report? yes
Feature request? yes/no
Swoft version 1.0.0
Swoole version 2.1.1
PHP version 7.1.4
Runtime environment Mac/CentOS 7

Details

协程环境下,redis 可以读写值,但是has方法会报错

   public function testCo(){
        go(function (){
            $client =new Redis();
            $client->set("a",1,10);
            var_dump($client->get('a'));
            $client->has('a');
        });
    }

Provide minimal script to reproduce the issue

string(1) "1"
PHP Warning:  Swoole\Coroutine\Redis::exists() expects parameter 1 to be string, array given in /Volumes/Work/service/vendor/swoft/framework/src/Helper/PhpHelper.php on line 46

Warning: Swoole\Coroutine\Redis::exists() expects parameter 1 to be string, array given in /Volumes/Work/service/vendor/swoft/framework/src/Helper/PhpHelper.php on line 46
PHP Fatal error:  Uncaught TypeError: Return value of Swoft\Redis\Redis::has() must be of the type boolean, null returned in /Volumes/Work/service/vendor/swoft/redis/src/Redis.php:221
Stack trace:
#0 /Volumes/Work/service/test/Cases/Common/RedisCoTest.php(23): Swoft\Redis\Redis->has('a')
#1 {main}
  thrown in /Volumes/Work/service/vendor/swoft/redis/src/Redis.php on line 221

Fatal error: Uncaught TypeError: Return value of Swoft\Redis\Redis::has() must be of the type boolean, null returned in /Volumes/Work/service/vendor/swoft/redis/src/Redis.php:221
Stack trace:
#0 /Volumes/Work/service/test/Cases/Common/RedisCoTest.php(23): Swoft\Redis\Redis->has('a')
#1 {main}
  thrown in /Volumes/Work/service/vendor/swoft/redis/src/Redis.php on line 221
whiteCcinn commented 6 years ago

查看merged的提交,issue已修复.