swoft-cloud / swoft

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

redis pool use hscan problem #1480

Open azhuang321 opened 2 years ago

azhuang321 commented 2 years ago
Q A
Bug report? yes
Feature request? no
Swoft version 2.0.11
Swoole version 4.8.9
PHP version 7.3.31
Runtime environment Ubuntu

Details

redis pool use hscan,but the iterator not change

            var_dump('hscan----------------------');
            $iterator = null;

//         use \Redis (right)
            $redis = new \Redis();
            $redisBean = \Swoft::getBean('redis');
            $redis->pconnect($redisBean->getHost(), $redisBean->getPort());
            !empty($redisBean->getPassword()) && $redis->auth($redisBean->getPassword());
            $redis->select($redisBean->getDatabase());
            $redis->setOption(\Redis::OPT_SCAN,\Redis::SCAN_RETRY);
            $redis->hScan(config('redisKey.uidFdRelation'), $iterator,'*',10);
            var_dump($iterator);

//use \Redis (right) output
//string(27) "hscan----------------------"
//int(320)

//            use pool(wrong)
//            $this->redisDb->setOption(\Redis::OPT_SCAN,\Redis::SCAN_RETRY);
//            $this->redisDb->hScan(config('redisKey.uidFdRelation'), $iterator,'*',20)
//           var_dump($iterator);

//use swoft redis pool (wrong) output
//string(27) "hscan----------------------"
//NULL