本文整理汇总了PHP中Memcached::getAllKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::getAllKeys方法的具体用法?PHP Memcached::getAllKeys怎么用?PHP Memcached::getAllKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::getAllKeys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listKeys
/**
* @see parent::listKeys()
*/
function listKeys($prefix)
{
// Memcached 2.0+
if (method_exists($this->conn, "getAllKeys")) {
return $this->conn->getAllKeys();
}
return array();
}
示例2: clear
public function clear($prefix = '')
{
$prefix = $this->getNamespace() . $prefix;
$allKeys = self::$cache->getAllKeys();
$keys = array();
$prefixLength = strlen($prefix);
foreach ($allKeys as $key) {
if (substr($key, 0, $prefixLength) === $prefix) {
$keys[] = $key;
}
}
self::$cache->deleteMulti($keys);
return true;
}
示例3: clear
public function clear($prefix = '')
{
$prefix = $this->getNamespace() . $prefix;
$allKeys = self::$cache->getAllKeys();
if ($allKeys === false) {
// newer Memcached doesn't like getAllKeys(), flush everything
self::$cache->flush();
return true;
}
$keys = array();
$prefixLength = strlen($prefix);
foreach ($allKeys as $key) {
if (substr($key, 0, $prefixLength) === $prefix) {
$keys[] = $key;
}
}
if (method_exists(self::$cache, 'deleteMulti')) {
self::$cache->deleteMulti($keys);
} else {
foreach ($keys as $key) {
self::$cache->delete($key);
}
}
return true;
}
示例4: mem
public function mem()
{
//$CI =& get_instance();
$m = new Memcached();
$m->addServer('localhost', 11211);
$res = $m->getAllKeys();
print_r($res);
}
示例5: 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->_Memcached->getAllKeys();
foreach ($keys as $key) {
if (strpos($key, $this->_config['prefix']) === 0) {
$this->_Memcached->delete($key);
}
}
return true;
}
示例6: keys
public static function keys(\Memcached $memcached, $regex = false)
{
$allKeys = $memcached->getAllKeys();
if (!$regex) {
return $allKeys;
}
$matchingKeys = [];
foreach ($allKeys as $key) {
if (preg_match($regex, $key) > 0) {
array_push($matchingKeys, $key);
}
}
return $matchingKeys;
}
示例7: delete
/**
* Delete one or several data from cache (* joker can be used, but avoid it !)
* E.g.: delete('*'); delete('my_prefix_*'); delete('my_key_name');
*
* @param string $key
* @return bool
*/
public function delete($key)
{
if ($key == '*') {
$this->flush();
} elseif (strpos($key, '*') === false) {
$this->_delete($key);
} else {
$pattern = str_replace('\\*', '.*', preg_quote($key));
$keys = $this->memcached->getAllKeys();
foreach ($keys as $key => $data) {
if (preg_match('#^' . $pattern . '$#', $key)) {
$this->_delete($key);
}
}
}
return true;
}
示例8: flushImpl
protected function flushImpl($cacheSubsetName) {
if (isset($cacheSubsetName)) {
$cacheEntryNames = $this->memcached->getAllKeys();
if ($cacheEntryNames === FALSE) {
return FALSE;
}
$result = TRUE;
foreach ($cacheEntryNames as $cacheEntryName) {
if ($this->inSubset($cacheSubsetName, $cacheEntryName)) {
$result = $this->memcached->delete($cacheEntryName) && $result;
}
}
return $result;
}
else {
return $this->memcached->flush();
}
}
示例9: _getAllKeys
/**
* {@inheritDoc}
*
* @see http://php.net/manual/en/memcached.getallkeys.php
*/
protected function _getAllKeys()
{
return $this->_connection->getAllKeys();
}
示例10: Memcached
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
// getAllKeys doesn't seem to work until after another operation
$m->get('a');
$keys = $m->getAllKeys();
if ($keys) {
array_map(function ($key) use($m) {
$m->delete($key);
}, $keys);
}
var_dump($m->getAllKeys());
$obj = new stdclass();
$obj->int = 99;
$obj->string = 'a simple string';
$obj->array = array(11, 22);
$m->set('int', 99);
$m->set('string', 'a simple string');
$m->set('array', array(11, 12));
$m->set('object', $obj);
var_dump($m->getAllKeys());
示例11: get_prefixed_keys
/**
* Returns all of the keys in the given connection that belong to this cache store instance.
*
* Requires php memcached extension version 2.0.0 or greater.
*
* @param Memcached $connection
* @param string $prefix
* @return array
*/
protected static function get_prefixed_keys(Memcached $connection, $prefix)
{
$connkeys = $connection->getAllKeys();
if (empty($connkeys)) {
return array();
}
$keys = array();
$start = strlen($prefix);
foreach ($connkeys as $key) {
if (strpos($key, $prefix) === 0) {
$keys[] = substr($key, $start);
}
}
return $keys;
}
示例12: trim
$listKeys = true;
// key
} else {
$key = trim($arg);
}
}
}
$mc = new Memcached();
$mc->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$mc->setOption(\Memcached::OPT_DISTRIBUTION, \Memcached::DISTRIBUTION_CONSISTENT);
$mc->addServer($host, $port);
$keys = [];
if ($key && strpos($key, '*') === false) {
$keys[] = $key;
} else {
$allKeys = $mc->getAllKeys();
if (strpos($key, '*') !== false) {
$keyPattern = '/^' . str_replace('*', '.*', $key) . '$/i';
foreach ($allKeys as $k) {
if (preg_match($keyPattern, $k)) {
$keys[] = $k;
}
}
} elseif ($listKeys) {
$keys = $allKeys;
}
}
foreach ($keys as $key) {
if ($listKeys) {
echo $key . PHP_EOL;
} else {
示例13: getAllKeys
/**
* tüm memcache key'lerini get eder
* @return array
*/
public function getAllKeys()
{
return $this->memcache->getAllKeys();
}
示例14: cleancache
function cleancache($uid)
{
$m = new Memcached();
$m->addServer('localhost', 11211);
$r = $m->getAllKeys();
$m->delete($uid . 'CE');
$m->delete('dates' . $uid);
$m->delete($uid . 'ext');
$m->delete($uid . 'saldo');
echo 1;
}
示例15: getAllKeys
/**
* @inheritdoc
*/
public function getAllKeys()
{
return $this->storage->getAllKeys();
}