本文整理汇总了PHP中Predis\ClientInterface::keys方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::keys方法的具体用法?PHP ClientInterface::keys怎么用?PHP ClientInterface::keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteGlob
private function deleteGlob($pattern)
{
$keys = $this->client->keys($pattern);
$options = $this->client->getOptions();
if (isset($options->prefix)) {
$length = strlen($options->prefix->getPrefix());
$keys = array_map(function ($key) use($length) {
return substr($key, $length);
}, $keys);
}
if (count($keys) === 0) {
return;
}
$this->client->del($keys);
}
示例2: clear
/**
* Delete all keys from the cache
*
* @param bool $check if true will check expiration, otherwise delete all
* @return bool True if the cache was successfully cleared, false otherwise
*/
public function clear($check)
{
if ($check) {
return true;
}
$keys = $this->client->keys($this->_config['prefix'] . '*');
foreach ($keys as $key) {
$this->client->del($key);
}
return true;
}
示例3: testKeys
/**
* @group redis-keys
*/
public function testKeys()
{
//$this->assertEquals(array(), $this->client->keys('derp'));
$items = array('hello' => 1, 'hallo' => 1, 'hxllo' => 1, 'hllo' => 1, 'heeeello' => 1, 'hillo' => 1, 'hbllo' => 1, 'color:red' => 'red', 'color:blue' => 'blue', 'color:green' => 'green', '[ns]foo' => 'bar');
$this->client->mset($items);
$this->assertArraySimilar(array('hello', 'hallo', 'hxllo', 'hbllo', 'hillo'), $this->client->keys('h?llo'));
$this->assertArraySimilar(array('hllo', 'hello', 'hallo', 'hxllo', 'hillo', 'hbllo', 'heeeello'), $this->client->keys('h*llo'));
$this->assertArraySimilar(array('hello', 'hallo'), $this->client->keys('h[ae]llo'));
$this->assertArraySimilar(array('hallo', 'hillo', 'hbllo', 'hxllo'), $this->client->keys('h[^e]llo'));
$this->assertArraySimilar(array('hallo', 'hbllo'), $this->client->keys('h[a-b]llo'));
$this->assertArraySimilar(array('color:green'), $this->client->keys('*en'));
$this->assertArraySimilar(array('[ns]foo'), $this->client->keys('\\[ns\\]*'));
$this->assertArraySimilar(array('color:red'), $this->client->keys('color:red'));
$this->assertArraySimilar(array_keys($items), $this->client->keys('*'));
}
示例4: getCountItems
/**
* @return int
*/
public function getCountItems()
{
return count($this->client->keys($this->getSearchPattern()));
}