本文整理匯總了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;
}