Cms: Move element/query recording out of the TemplateCaches service

Created on 13 Mar 2017  路  3Comments  路  Source: craftcms/cms

That way plugins could initiate their own template recorders, and use the resulting collections for their own purposes, unrelated to Craft's own caching system (for example, they could be used as Varnish dependencies).

enhancement extensibility

Most helpful comment

This is resolved for Craft 3.5. (885912438eb9c8929152552524d632bb0a6b514f)

We鈥檙e using this new system for template caches ({% cache %} tags) and GraphQL query caches. Here鈥檚 the GraphQL code, as that鈥檚 a simpler example, since it doesn鈥檛 have to worry about nested caches like template caches do:

https://github.com/craftcms/cms/blob/885912438eb9c8929152552524d632bb0a6b514f/src/services/Gql.php#L417-L440

https://github.com/craftcms/cms/blob/885912438eb9c8929152552524d632bb0a6b514f/src/services/Gql.php#L478-L488

All 3 comments

This is resolved for Craft 3.5. (885912438eb9c8929152552524d632bb0a6b514f)

We鈥檙e using this new system for template caches ({% cache %} tags) and GraphQL query caches. Here鈥檚 the GraphQL code, as that鈥檚 a simpler example, since it doesn鈥檛 have to worry about nested caches like template caches do:

https://github.com/craftcms/cms/blob/885912438eb9c8929152552524d632bb0a6b514f/src/services/Gql.php#L417-L440

https://github.com/craftcms/cms/blob/885912438eb9c8929152552524d632bb0a6b514f/src/services/Gql.php#L478-L488

@brandonkelly Great work! Just a heads-up, I was playing with this and if you don't create a query within the cache tag (for example, using the matched element (entry.title) instead, the cache is not automatically invalidated when the corresponding entry saves.

Does not clear on entry save:

{% cache %}
{{ entry.title }}
{% endcache %}

Does clear on entry save:

{% cache %}
    {% set entry = craft.entries.section('homepage').one() %}
    <h1>{{ entry.test }}</h1>
{% endcache %}

@Mosnar I caught that yesterday as well. Should be fixed via decc3313bbbf63249bbf76903ed5f068fe3fd781.

Was this page helpful?
0 / 5 - 0 ratings