Hi all,
I want to use http://www.lullabot.com/articles/a-beginners-guide-to-caching-data
this method in my custom module, but I can not get it work, want someone can help to check my code where is can be correct, my custom module function:
function cache_dev_news_page() {
static $my_data;
if (!isset($my_data) || $reset) {
if (!$reset && ($cache = cache_get('my_module_data')) && !empty($cache->data)) {
$my_data = unserialize($cache->data);
}
else {
$sql = "SELECT * FROM {node} WHERE type = 'news' AND status = 1 ORDER BY created DESC";
$result = pager_query($sql, NORMAL_PAGE_LIMIT);
$news_nodes = array();
while ($data = db_fetch_object($result)) {
$news_nodes[] = l($data->title, 'node/' . $data->nid) . format_date($data->created);
}
$output = theme('item_list', $news_nodes);
$output .= theme('pager', NULL, NORMAL_PAGE_LIMIT);
return $output;
cache_set('my_module_data', 'cache', serialize($my_data));
}
}
return $my_data;
}
thanks advance!