How to clear twig cache by key?

mattcdavis1 - 7 months ago

Craft CMS has a deleteCacheById() method but not sure what Pyro has. I suppose this would be a non-issue if the database driver worked but in the meantime is there currently a way to clear cache by key?

ryanthompson - 7 months ago

Can you explain "if the database driver worked"? There is no cache clearing by key within the twig template. You could try flushCache is all.. or are you referring to Twig specific cache and not model bound cache?

mattcdavis1 - 7 months ago

  • As far as the database issue - was referring to this: https://github.com/pyrocms/pyrocms/issues/4297
  • Was referring to twig specific cache. So if i do this:
    {% cache 'my-cache-key' 9000 %}
    {% include 'theme::real-estate.properties.' ~ layout %}
    {% endcache %}

How would i clear just "my-cache-key" from twig cache?

Now that the database driver is working, i can just run a SQL query to delete this entry but wan't sure if there was a way to do this through twig like Craft has ("deleteCacheById()")

BTW - there is some funky parsing going on with these forum comments. if i use backticks at any point after my first set of backticks it throws in a bunch of content from another area in my comment.