Mity Docs Mity Docs for Mity Digital
Scheduled Cache Invalidator Documentation

Query Scopes

You can use Query Scopes with the Scheduled Cache Invalidator, and apply these globally to all invalidator logic, or per Collection.

To set these up, you will need to publish the configuration file if you haven't already done so.

v2 New

v2 of the Scheduled Cache Invalidator changes the behaviour of how to hook up your Query Scopes. You can now apply to:

  • single scope to all Collections

  • multiple scopes to all Collections

  • single scope to specific Collections

  • multiple scopes to specific Collections

This is considered a breaking change as while the configuration remains the same, the impact may be unexpected for v1 users, as Undated collections may now be queried too if using a global scope.

All

When configured this way, your Query Scope will be applied to the Invalidator's logic for every collection.

Your config for query_scopes should be a path to your query scope:

1'query_scopes' => \Path\To\Scope::class,

You can also set an array to apply multiple scopes to the logic:

1'query_scopes' => [
2 \Path\To\Scope::class,
3 \Path\To\AnotherScope::class
4],

Collection-specific

When configured for individual collections, you can define a different Query Scope for each (some or all) Collection in your site.

Your config for query_scopes should be an array, key of your collection handle, value to your query scope:

1'query_scopes' => [
2 'collection_a' => \Path\To\Scope::class,
3 'collection_b' => \Path\To\DifferentScope::class,
4],

Just like the "All" above, you can also pass an array for each Collection (or a combination of an array and a single scope):

1'query_scopes' => [
2 'collection_a' => [
3 \Path\To\Scope::class,
4 \Path\To\AnotherScope::class
5 ],
6 'collection_b' => [
7 \Path\To\AnotherScope::class
8 ],
9 'collection_c => \Path\To\Scope::class,
10],

When using Collections, you do not need to apply a Query Scope to all collections - only those you want to use.

v1

All

When configured this way, your Query Scope will be applied to the Invalidator's logic for every collection.

Your config for query_scopes should be a path to your query scope:

1'query_scopes' => \Path\To\Scope::class,

Collection-specific

When configured for individual collections, you can define a different Query Scope for each (some or all) Collection in your site.

Your config for query_scopes should be an array, key of your collection handle, value to your query scope:

1'query_scopes' => [
2 'collection_a' => \Path\To\Scope::class,
3 'collection_b' => \Path\To\DifferentScope::class,
4],

When using Collections, you do not need to apply a Query Scope to all collections - only those you want to use.