示例#1
0
文件: ListType.php 项目: ig-hit/redis
 /**
  * @param string $key
  * @return int
  */
 public function count($key = '')
 {
     if (!$key) {
         return 0;
     }
     return $this->client->lLen($key);
 }
示例#2
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;
             }
         }
     }
 }
示例#3
0
 /**
  * @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;
             }
         }
     }
 }
示例#4
0
 /**
  * @param $key
  * @param int $by
  * @return float|int
  */
 public function increment($key, $by = 1, $fldName = null)
 {
     return $this->client->incrByFloat($key, $by);
 }