This project is not covered by Drupal’s security advisory policy.

It is recommended to work on the D8Cache module instead, this module is unsupported.


CacheTags is an experimental project to associate cache entries with metadata, which then enables developers to clear caches based on that metadata.

Basic syntax:

cache_set('some_cid', 'my data', 'cache', time() + $expire, array('node' => array(2, 4), 'user' => array(1, 3)));

This tags the entry with node ID's 2 and 4, and user ID 1 and 3. The entry can then be expired by any combination of those IDs:

cache_invalidate(array('user' => array(1)));

A cache_get() for entries tagged with user ID 1 will subsequently return FALSE, and if the cache is not re-populated, data will be cleaned up after $expire seconds.

Core version status

  • 8.x: CacheTags functionality exists in Drupal 8.x, see the API documentation for full details.
  • 7.x: core patch simply modifies arguments of cache_set(). Implementation provided as a cache plugin and schema alter module.
  • 6.x: no core patch, implementation exists as a cache plugin and schema alter module.

Note: automatic code testing has been disabled in the issue queue as I'm not aware of any way to apply the necessary core patches (for D7) via the testing system.

Backend support

Currently there is support for:

Tag counters have their own pluggable storage which may use a different backend than the cache bins themselves.

Credits / Contact

Currently maintained by Dick Olson and Damien McKenna. All initial development was by Carlos Rodriguez.

Continued development sponsored by Al Jazeera and Mediacurrent.

Project Information

Downloads