批量删除redis或memcached缓存

public function cleanCache(){
        $keys = $this->redis->keys(self::CACHE_PREFIX.'*');
        foreach($keys as $key){
            $r = $this->redis->delete($key);
            echo $key.'---'.$r."<br>".PHP_EOL;
            ob_flush();
            flush();
        }
    }
	
$keys = $cache->getAllKeys();
$regex = 'product_.*';
foreach($keys as $item) {
    if(preg_match('/'.$regex.'/', $item)) {
        $cache->delete($item);
    }
}