/**
* Clean cache for a group given a mode.
*
* group mode : cleans all cache in the group
* notgroup mode : cleans all cache not in the group
*
* @param string $group The cache data group
* @param string $mode The mode for cleaning cache [group|notgroup]
*
* @return boolean
*
* @since 3.5
*/
public function clean($group, $mode = null)
{
$allinfo = apcu_cache_info();
$keys = $allinfo['cache_list'];
$secret = $this->_hash;
foreach ($keys as $key) {
if (isset($key['info'])) {
// The internal key name changed with APCu 4.0.7 from key to info
$internalKey = $key['info'];
} elseif (isset($key['entry_name'])) {
// Some APCu modules changed the internal key name from key to entry_name
$internalKey = $key['entry_name'];
} else {
// A fall back for the old internal key name
$internalKey = $key['key'];
}
if (strpos($internalKey, $secret . '-cache-' . $group . '-') === 0 xor $mode !== 'group') {
apcu_delete($internalKey);
}
}
return true;
}