CacheTags is an experimental project to associate cache entries with metadata, which then
enables developers to clear caches based on that metadata.
Basic syntax:
<?php
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:
<?php
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: core patch contains most of the implementation and represents tentative inclusion in Drupal core. See #636454: Cache tag support for that initiative.
cachetags_sqlmodule provided to enable the modified schema on existing sites. - 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.
Downloads
Recommended releases
Development releases
Project Information
- Maintenance status: Actively maintained
- Development status: Under active development
- Reported installs: 7 sites currently report using this module. View usage statistics.
- Downloads: 502
- Last modified: April 21, 2013