本文整理汇总了PHP中Memcache::deleteMulti方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::deleteMulti方法的具体用法?PHP Memcache::deleteMulti怎么用?PHP Memcache::deleteMulti使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcache
的用法示例。
在下文中一共展示了Memcache::deleteMulti方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteMany
/**
* Delete many keys from the cache at once
*
* @param array $keys An array of identifiers for the data
* @return array of boolean values that are true if the key was successfully deleted, false if it didn't exist or
* couldn't be removed
*/
public function deleteMany($keys)
{
$cacheKeys = array();
foreach ($keys as $key) {
$cacheKeys[] = $this->_key($key);
}
$success = $this->_Memcached->deleteMulti($cacheKeys);
$return = array();
foreach ($keys as $key) {
$return[$key] = $success;
}
return $return;
}
示例2: delete
/**
* 删除指定key的缓存,若$key===true则表示删除全部
*
* @param string $key
*/
public function delete($key)
{
$this->_connect();
if (true === $key) {
if (Cache_Driver_Memcache::$_memcached_mode) {
$status = $this->_memcache->flush(1);
} else {
$status = $this->_memcache->flush();
if ($status) {
// We must sleep after flushing, or overwriting will not work!
// @see http://php.net/manual/en/function.memcache-flush.php#81420
sleep(1);
}
}
} else {
if (is_array($key)) {
# 加前缀
if ($this->prefix) {
foreach ($key as &$k) {
$k = $this->prefix . $k;
}
}
if (Cache_Driver_Memcache::$_memcached_mode) {
$status = $this->_memcache->deleteMulti($key);
} else {
# 循环的删除
foreach ($key as $k) {
$this->_memcache->delete($k);
}
$status = true;
}
} else {
$status = $this->_memcache->delete($this->prefix . $key);
}
}
if (IS_DEBUG) {
Core::debug()->info($key, 'memcache delete key');
}
return $status;
}