本文整理汇总了PHP中Zend\Cache\Storage\Adapter\AbstractAdapter::internalRemoveItems方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractAdapter::internalRemoveItems方法的具体用法?PHP AbstractAdapter::internalRemoveItems怎么用?PHP AbstractAdapter::internalRemoveItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Cache\Storage\Adapter\AbstractAdapter
的用法示例。
在下文中一共展示了AbstractAdapter::internalRemoveItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: internalRemoveItems
/**
* Internal method to remove multiple items.
*
* @param array $normalizedKeys
* @return array Array of not removed keys
* @throws Exception\ExceptionInterface
*/
protected function internalRemoveItems(array &$normalizedKeys)
{
$memc = $this->getMemcachedResource();
// support for removing multiple items at once has been added in ext/memcached-2.0.0
// and HHVM doesn't support this feature yet
if (!method_exists($memc, 'deleteMulti')) {
return parent::internalRemoveItems($normalizedKeys);
}
foreach ($normalizedKeys as &$normalizedKey) {
$normalizedKey = $this->namespacePrefix . $normalizedKey;
}
$missingKeys = [];
foreach ($memc->deleteMulti($normalizedKeys) as $normalizedKey => $rsCode) {
if ($rsCode !== true && $rsCode != MemcachedResource::RES_SUCCESS) {
if ($rsCode != MemcachedResource::RES_NOTFOUND) {
throw $this->getExceptionByResultCode($rsCode);
}
$missingKeys[] = $normalizedKey;
}
}
// remove namespace prefix
if ($missingKeys && $this->namespacePrefix !== '') {
$nsPrefixLength = strlen($this->namespacePrefix);
foreach ($missingKeys as &$missingKey) {
$missingKey = substr($missingKey, $nsPrefixLength);
}
}
return $missingKeys;
}
示例2: internalRemoveItems
/**
* Internal method to remove multiple items.
*
* @param array $normalizedKeys
* @return array Array of not removed keys
* @throws Exception\ExceptionInterface
*/
protected function internalRemoveItems(array &$normalizedKeys)
{
// support for removing multiple items at once has been added in ext/memcached-2.0.0
if (static::$extMemcachedMajorVersion < 2) {
return parent::internalRemoveItems($normalizedKeys);
}
$memc = $this->getMemcachedResource();
foreach ($normalizedKeys as &$normalizedKey) {
$normalizedKey = $this->namespacePrefix . $normalizedKey;
}
$rsCodes = $memc->deleteMulti($normalizedKeys);
$missingKeys = array();
foreach ($rsCodes as $key => $rsCode) {
if ($rsCode !== true && $rsCode != MemcachedResource::RES_SUCCESS) {
if ($rsCode != MemcachedResource::RES_NOTFOUND) {
throw $this->getExceptionByResultCode($rsCode);
}
$missingKeys[] = $key;
}
}
// remove namespace prefix
if ($missingKeys && $this->namespacePrefix !== '') {
$nsPrefixLength = strlen($this->namespacePrefix);
foreach ($missingKeys as &$missingKey) {
$missingKey = substr($missingKey, $nsPrefixLength);
}
}
return $missingKeys;
}
示例3: internalRemoveItems
/**
* Internal method to remove multiple items.
*
* Options:
* - namespace <string>
* - The namespace to use
* - ignore_missing_items <boolean>
* - Throw exception on missing item
*
* @param array $keys
* @param array $options
* @return boolean
* @throws Exception\ExceptionInterface
*/
protected function internalRemoveItems(array &$normalizedKeys, array &$normalizedOptions)
{
// support for removing multiple items at once has been added in ext/memcached-2.0.0
if (static::$extMemcachedMajorVersion < 2) {
return parent::internalRemoveItems($normalizedKeys, $normalizedOptions);
}
$this->memcached->setOption(MemcachedResource::OPT_PREFIX_KEY, $normalizedOptions['namespace']);
$rsCodes = $this->memcached->deleteMulti($normalizedKeys);
$missingKeys = null;
foreach ($rsCodes as $key => $rsCode) {
if ($rsCode !== true && $rsCode != 0) {
if ($rsCode != MemcachedResource::RES_NOTFOUND) {
throw $this->getExceptionByResultCode($rsCode);
}
$missingKeys[] = $key;
}
}
if ($missingKeys && !$normalizedOptions['ignore_missing_items']) {
throw new Exception\ItemNotFoundException("Keys '" . implode("','", $missingKeys) . "' not found within namespace '{$normalizedOptions['namespace']}'");
}
return true;
}