Views Cache Expirator
Component ID
1452304
Component name
Views Cache Expirator
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
This is a simple API module for easy Views cache expiration.
Don't install this module if you are not a developer or some module declare this module as dependency.
You may consider similar alternatives:
Example implementation:
/**
* Implements hook_node_insert().
*/
function mymodule_node_insert($node) {
mymodule_node_invalidate_views_cache($node);
}
/**
* Implements hook_node_update().
*/
function mymodule_node_update($node) {
mymodule_node_invalidate_views_cache($node);
}
/**
* Implements hook_node_delete().
*/
function mymodule_node_delete($node) {
mymodule_node_invalidate_views_cache($node);
}
/**
* Implements hook_node_revision_delete().
*/
function mymodule_node_revision_delete($node) {
mymodule_node_invalidate_views_cache($node);
}
/**
* Map views invalidation to node type updates.
*
* @param object $node
*/
function mymodule_node_invalidate_views_cache($node) {
switch ($node->type) {
case 'article':
views_cache_expirator_clear_view('homepage', 'block_1');
break;
case 'blog':
views_cache_expirator_clear_view('blogs');
views_cache_expirator_clear_view('homepage', 'block_1');
break;
}
Credits
Developed by Ants at Atomic Ant Ltd.
