cacheManager->flush isn't supported
Issue:
flushing cache in front end has to be done via the cacheManager - eg. to 'uncache' a eg. page it would be:
/** @var \TYPO3\CMS\Core\Cache\CacheManager */
$cacheManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class);
$cacheManager->flushCachesByTag('pageId_'.$pid);
//or $cacheManager->flushCachesInGroupByTags('pages', [ 'pageId_'.$pid ]);
how ever the extension never sees this ( and as it turns out can't because there are no hooks in the cacheManager class or the cacheBackends )
The only way to fix it is to instanciate the VarnishController and repeat the cacheCommand to it directly:
/** @var \Opsone\Varnish\Controller\VarnishController $varnishController */
$varnishController = GeneralUtility::makeInstance(\Opsone\Varnish\Controller\VarnishController::class);
$varnishController->clearCache('pageId_'.$pid);
It works but it does take away for the transparent nature of varnish/this extension.
Perhaps it would be worth asking for hooks for the various flush* commands?
Especially since it could happen in other peoples extensions as that may not want code for a specific extension littering their codebase