function blockcache_alter_block_view in Block Cache Alter 6
View a cached block using hook_block(). If the block is not cached or the cache is stale, get the info and stick it back into the cache.
1 call to blockcache_alter_block_view()
- blockcache_alter_block in ./
blockcache_alter.module - Implementation of hook_block().
File
- ./
blockcache_alter.module, line 468 - Block Cache alter.
Code
function blockcache_alter_block_view($delta) {
$d = explode(",", $delta);
$module = $d[0];
$delta = $d[1];
$cid = _blockcache_alter_get_cache_id($module, $delta);
if ($cid && ($cache = cache_get($cid, 'cache_block'))) {
$array = $cache->data;
}
else {
$array = module_invoke($module, 'block', 'view', $delta);
if (isset($cid)) {
$blocklife = variable_get('bc_life_' . $module . '_' . $delta, '');
$blocklife = (int) $blocklife + time();
cache_set($cid, $array, 'cache_block', $blocklife);
if ($debug = variable_get('bca_debug', FALSE) && user_access('administer site configuration')) {
drupal_set_message('block re-cached: ' . $block->title . '_' . $module . '_' . $delta . '_' . $blocklife . '_' . time());
}
}
}
return $array;
}