How to flush/clean cache programmatically in Magento 2.4 for category/product page

Like I mentioned in my question I am having problem with clean/flushing cache on category/product pages.

I get some code, probably for some older version of Magento but didn’t work.

Here it is:

    $cacheTag = MagentoCatalogModelCategory::CACHE_TAG . '_' . $catId;
    $category = $this->categoryRepository->get($catId, $this->storeManager->getStore()->getId());

    $this->cacheManager->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, [$cacheTag]);
    $this->eventManager->dispatch('clean_cache_by_tags', ['object' => $category]);

Same example I found here:

https://magecomp.com/blog/clear-cache-for-specific-cms-page-programmatically-in-magento-2/

I check Manager class and method clean have only one parameter(argument) an this is an array of types. So I tried with one argument and I get one error: Notice: Undefined index: instance in /app/vendor/magento/framework/App/Cache/TypeList.php on line 75

So is there any other way how to clean cache on category or product page?

Tnx for help.