How to clear the data cache in an action

Hello to all,

do I have a possibility to clear the data cache for one specific view? In my case I need to show the available ticket amount without any caching.

For example: https://www.volkmetaljacket.com/de/tickets

So found hints like this

$this->get(\Pimcore\Bundle\CoreBundle\EventListener\Frontend\FullPageCacheListener::class)->disable(“No caching because of available ticket amount”);

or

// clear the whole cache
\Pimcore\Cache::clearAll();

but I don’t want to disable the full page cache or clearing all caches but clearing the data cache in the relevant action. (source code)

Thx for your help!

Best,
Kris

Hi,
if you have fullpage cache activated for you page (at least when you have also specified a lifetime), then you will have to deactivate the fullpage cache for the action - best would be via the excluded pattern option in settings, or in controller like you wrote above.

Clearing data cache should not be necessary if you have stored available ticket in Pimcore data objects, since Pimcore takes care of cache invalidation and in cache there should always be the most current information.

BR
Christian

Hi,

thx a lot. Will give the exclude pattern a try 'cause administration via backend is a bit more flexible instead of doing that in source code!

Best,
Kris