예제 #1
0
파일: SetType.php 프로젝트: ig-hit/redis
 /**
  * @param $key
  * @param null $matchPattern
  * @param int $cnt
  *
  * @return \Generator
  */
 public function find($key, $matchPattern = null, $cnt = 1000)
 {
     $it = null;
     $this->client->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY);
     $redis = $this->client->getRedis();
     while ($arr = $redis->sScan($key, $it, $matchPattern, $cnt)) {
         foreach ($arr as $value) {
             $cmd = (yield $value);
             if ($cmd and strtolower($cmd) == 'break') {
                 return;
             }
         }
     }
 }
예제 #2
0
파일: RedisData.php 프로젝트: ig-hit/redis
 /**
  * @param $keyPattern
  * @return \Generator
  */
 public function find($keyPattern, $match = null, $cnt = 1000)
 {
     $it = null;
     $this->client->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);
     $redis = $this->client->getRedis();
     $keyPattern = $this->ns . $keyPattern;
     while ($arr_keys = $redis->scan($it, $keyPattern, $cnt)) {
         foreach ($arr_keys as $key) {
             $c = str_replace($this->ns, '', $key);
             $v = $this->get($c);
             $cmd = (yield $c => $v);
             if ($cmd and strtolower($cmd) == 'break') {
                 return;
             }
         }
     }
 }