/**
* 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.4
*/
public function clean($group, $mode = null)
{
if (static::isConnected() == false) {
return false;
}
$allKeys = static::$_redis->keys('*');
if ($allKeys === false) {
$allKeys = array();
}
$secret = $this->_hash;
foreach ($allKeys as $key) {
if (strpos($key, $secret . '-cache-' . $group . '-') === 0 && $mode === 'group') {
static::$_redis->del($key);
}
if (strpos($key, $secret . '-cache-' . $group . '-') !== 0 && $mode !== 'group') {
static::$_redis->del($key);
}
}
return true;
}