Cache items by tags


I am using the CACHE component a lot, And on thing i see the cache component lacks is the ability to define tags for cache items so several items can be grouped into one tag so when you want to drop all items with one call you can by defining the tag to delete all items who uses that tag. That’s a feature that exists and works well in ZF cache component.

For example you could do:

Yii::app()->cache->set('item_name', $item_data, $expires, array( 'group1', 'group2' ));

Then you will be able to delete all cached items with the group by name for example:



Yii::app()->cache->delete(array( 'group1', 'group2' ));

Of course something like this is not that hard to achieve by extending the classes but i do think a default implementation is something that will be used by developer often.


See here.