Problem/Motivation

To implement Cache Tags in Drupal 7, the API for adding cache tags needs to be standardized.

Of course contrib could take over that task, but an API as fundamental as this one belongs into Core.

Proposed resolution

Add the following API functions to Drupal 7 core:

- drupal_add_cache_tags(array $keys)
- drupal_get_cache_tags()
- drupal_invalidate_cache_tags(array $keys)
- hook_cache_tags_invalidate(array $keys)

and (optionally) allow the same syntax as in Drupal 8:

- $build['#cache']['tags'][] = $key;

( which internally would be stored simply as ['#attached']['drupal_add_cache_tags'] and would also be the way how cache backends supporting tagging would access the data )

--

Core would by default not implement any functionality in itself to generate checksums or implement the hook itself, but would just provide the API and functions for other contrib modules to do so. (e.g. the glue)

--

It is intentional that drupal_add_cache_tags() can change the global state as the API should be as simple as possible to use and Attachment Collector should take care of not loosing any data.

Remaining tasks

- Discuss
- Create a patch
- Discuss more
- Commit :)

User interface changes

- None

API changes

- Only API additions

Data model changes

- None

Comments

Fabianx created an issue.