function sharedblocks_cache_refresh in Shared Blocks 7.2
Refresh the cached content for the given shared block. The updated data is returned.
Parameters
string $block_name Machine name for block:
Return value
mixed Array of block data, NULL on error
1 call to sharedblocks_cache_refresh()
- sharedblocks_block_view in ./
sharedblocks.module - Implements hook_block_view().
File
- ./
sharedblocks.subscribe.inc, line 36 - Subscribe block page callbacks for the sharedblocks module.
Code
function sharedblocks_cache_refresh($block_name) {
$block_data = NULL;
$block = sharedblocks_subscription_load($block_name);
$cache_id = 'sharedblocks:' . $block_name;
$response = _sharedblocks_fetch_url($block->url);
if ($response) {
// Block exists: pull its information into an object.
$block_data = $response;
// Determine when the store content should expire
if ($block->update_interval > 0) {
$block_expiry = time() + $block->update_interval;
}
else {
$block_expiry = CACHE_TEMPORARY;
}
// Cache the block contents and set it to expire later
cache_set($cache_id, $block_data, 'cache_block', $block_expiry);
}
return $block_data;
}