当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::keys方法代码示例

本文整理汇总了PHP中Predis\Client::keys方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::keys方法的具体用法?PHP Client::keys怎么用?PHP Client::keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Predis\Client的用法示例。


在下文中一共展示了Client::keys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTextsByUser

 /**
  * @param $hostUid
  * @param $key
  * @return null|UserText
  */
 public function getTextsByUser($hostUid, $cached = true)
 {
     if ($cached) {
         $pattern = $this->buildKey($hostUid, '*', '*');
         $prefix = $this->redis->getOptions()->prefix;
         $redisKeys = array_map(function ($redisKey) use($prefix) {
             if (substr($redisKey, 0, strlen($prefix)) == $prefix) {
                 $redisKey = substr($redisKey, strlen($prefix));
             }
             return $redisKey;
         }, $this->redis->keys($pattern));
         if (count($redisKeys) > 0) {
             $result = array_combine($redisKeys, $this->redis->mget($redisKeys));
             foreach ($result as $redisKey => $text) {
                 list(, , $userId, , $key, $lang) = explode(':', $redisKey);
                 $this->texts[$userId][$key][$lang] = $text;
             }
         }
     }
     if (!$cached || !isset($this->texts[$hostUid]) || !$this->texts[$hostUid]) {
         $this->texts[$hostUid] = $this->getTextsByHostFromMysql($hostUid);
         $mset = [];
         foreach ($this->texts[$hostUid] as $key => $langs) {
             foreach ($langs as $lang => $text) {
                 $mset[$this->buildKey($hostUid, $key, $lang)] = $text;
             }
         }
         if ($mset) {
             $this->redis->mset($mset);
         }
     }
     return $this->texts[$hostUid];
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:38,代码来源:DataProvider.php

示例2: copy

 /**
  * function that takes all keys from source redis, dumps them and imports to the new redis
  */
 public function copy()
 {
     // retrieve all keys from source redis
     $keys = $this->source->keys('*');
     $this->out("Processing %d REDIS keys ...", count($keys), true);
     $hundred = 0;
     $step = 0;
     foreach ($keys as $key) {
         // check for ignored keys and skip the key if it should be ignored
         foreach ($this->ignoredPrefixes as $ignoredPrefix) {
             if (strpos($key, $ignoredPrefix) !== false) {
                 $this->out('.');
                 continue 2;
                 // continue with the next key
             }
         }
         try {
             $ttl = max(0, (int) $this->source->ttl($key));
             $serializedValue = $this->source->dump($key);
             $this->destination->restore($key, $ttl, $serializedValue);
         } catch (Exception $e) {
             $this->out(PHP_EOL . 'ERROR: ' . $key . PHP_EOL);
         }
         if ($step++ % 100 == 0) {
             $this->out(PHP_EOL . $hundred++ . ': ');
         }
         $this->out('o');
     }
     $this->out(PHP_EOL . PHP_EOL);
 }
开发者ID:becquerel,项目名称:redis-copy,代码行数:33,代码来源:RedisCopy.php

示例3: all

 /**
  * @return array
  * @throws UnavailableException
  */
 public function all()
 {
     try {
         return $this->client->keys('*');
     } catch (ServerException $ex) {
         throw new UnavailableException($ex->getMessage());
     }
 }
开发者ID:RepoMon,项目名称:tokens,代码行数:12,代码来源:Redis.php

示例4: getKeys

 /**
  * @param $queueName
  */
 private function getKeys($queueName, $useCache = false)
 {
     if (empty($this->keys) || !$useCache) {
         $this->keys = $this->redis->keys($this->getKeyPrefix($queueName) . '*');
     }
     $prefix = (string) $this->redis->getOptions()->prefix;
     $this->keys = array_map(function ($key) use($prefix) {
         return preg_replace('/^' . $prefix . '/', '', $key);
     }, $this->keys);
     return $this->keys;
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:14,代码来源:RedisQueue.php

示例5: removeWithName

 /**
  * @param $key
  *
  * @return int
  */
 public function removeWithName($key)
 {
     $result = 0;
     // se key ha l'asterisco, cancella tutte le chiavi che iniziano per il prefisso in $key
     if (strpos($key, '*') !== false) {
         foreach ($this->redis->keys($key) as $k) {
             $result += $this->redis->del($k);
         }
     } else {
         $result += $this->redis->del($key);
     }
     return $result;
 }
开发者ID:GruppoMeta,项目名称:Movio,代码行数:18,代码来源:QueryRedis.php

示例6: invalidate

 /**
  * @param string $providerPrefix
  *
  * @return bool
  */
 public function invalidate($providerPrefix)
 {
     $keys = $this->client->keys($this->prefix . strtolower($providerPrefix) . '_*');
     foreach ($keys as $key) {
         $this->client->del($key);
     }
     return true;
 }
开发者ID:paul-schulleri,项目名称:adform-client,代码行数:13,代码来源:RedisCache.php

示例7: getIds

 /**
  * Returns an array of cache ids.
  *
  * @param string $prefix Optional id prefix
  * @return array An array of cache ids
  */
 public function getIds($prefix = null)
 {
     if ($prefix) {
         return $this->_redis->keys($this->_getNamespacedId($prefix) . '*');
     } else {
         return $this->_redis->keys($this->_getNamespacedId('*'));
     }
 }
开发者ID:realestateconz,项目名称:SncRedisBundle,代码行数:14,代码来源:RedisCache.php

示例8: stringGetByPattern

 /**
  * Get string values from storage using a valid key pattern
  * @param string $pattern   the pattern
  * @return array            an array of string values
  */
 public function stringGetByPattern($pattern)
 {
     $keys = $this->_redis->keys($pattern);
     $values = [];
     foreach ($keys as $key) {
         $values[] = $this->stringRead($key);
     }
     return $values;
 }
开发者ID:haberberger,项目名称:redisstoragebundle,代码行数:14,代码来源:RedisStorage.php

示例9: getMany

 /**
  * @param ModelInterface $model
  * @param array $ids
  * @return array
  */
 public function getMany(ModelInterface $model, array $ids = [])
 {
     $table = $this->getTableName($model);
     $this->db->multiExec();
     $data = [];
     if (empty($ids)) {
         $keys = $this->db->keys($table . ':*');
         foreach ($keys as $key) {
             $json = $this->db->get($key);
             $data[] = $model->fromRaw(json_decode($json));
         }
     } else {
         foreach ($ids as $id) {
             $data[] = $this->getById($model, $id);
         }
     }
     return $data;
 }
开发者ID:alexdevid,项目名称:darinaerde,代码行数:23,代码来源:Storage.php

示例10: flushRedisCache

 private function flushRedisCache($pattern)
 {
     $config = config('database.redis.' . config('cache.stores.redis.connection'));
     $client = new Redis(['scheme' => 'tcp', 'host' => $config['host'], 'port' => $config['port'], 'parameters' => ['password' => $config['password'], 'database' => $config['database']]]);
     $keys = $client->keys('collejo:criteria:' . str_replace('\\', '\\\\', $pattern) . ':*');
     foreach ($keys as $key) {
         $client->del($key);
     }
 }
开发者ID:codebreez,项目名称:collejo-core,代码行数:9,代码来源:ClearCriteriaCache.php

示例11: getIterator

 /**
  * {@inheritdoc}
  */
 public function getIterator()
 {
     // TODO optimize the shit out of this crap
     $keys = $this->redis->keys('*');
     $values = array_map(function ($key) {
         return $this->redis->get($key);
     }, $keys);
     $array = array_combine($keys, $values);
     return new ArrayIterator($array);
 }
开发者ID:mnapoli,项目名称:blackbox,代码行数:13,代码来源:RedisStorage.php

示例12: clearCache

 /**
  * Delete all keys from redis
  */
 protected function clearCache()
 {
     $this->logger->info('Clearing cache...');
     $keys = $this->redis->keys('elogank.api.*');
     if (null != $keys) {
         foreach ($keys as $key) {
             $this->redis->del($key);
         }
     }
 }
开发者ID:phxlol,项目名称:lol-php-api,代码行数:13,代码来源:ApiManager.php

示例13: findSidsInRedis

 /**
  * @return array
  */
 public function findSidsInRedis()
 {
     $prefix = (string) $this->redis->getOptions()->prefix;
     $pattern = $this->getKey('');
     $prefixWithPattern = $prefix . $pattern;
     $keys = $this->redis->keys($pattern . '*');
     $sids = array_map(function ($key) use($prefixWithPattern) {
         return str_replace($prefixWithPattern, '', $key);
     }, $keys);
     return $sids;
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:14,代码来源:DataProvider.php

示例14: getKeys

 public function getKeys($pattern = '*')
 {
     $prefix = null;
     if ($this->client->getOptions()->__isset("prefix")) {
         $prefix = $this->client->getOptions()->__get("prefix")->getPrefix();
     }
     $keys = $this->client->keys($pattern);
     if ($prefix) {
         if (is_array($keys)) {
             for ($i = 0; $i < count($keys); $i++) {
                 $keys[$i] = str_replace($prefix, '', $keys[$i]);
             }
         } else {
             $keys = str_replace($prefix, '', $keys);
         }
     }
     return $keys;
 }
开发者ID:splitio,项目名称:php-client,代码行数:18,代码来源:PRedis.php

示例15: keys

 /**
  * Get all keys within the namespace.
  *
  * @return array
  */
 public function keys($namespace)
 {
     return $this->client->keys($namespace);
 }
开发者ID:molovo,项目名称:amnesia,代码行数:9,代码来源:Predis.php


注:本文中的Predis\Client::keys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。