Cache time

From: Date: Thu, 06 Mar 2003 11:02:04 +0000
Subject: Cache time
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8432@lists.php.net to get a copy of this message
Hi, In one of my current projects I need to test whether a template's cache is newer than the data from a database. In detail, the site has a news ticker system that isn't updated very often. The news are saved in a database. For the front page I want to fetch the titles of all topical news and pass them to the template. Since I want to cache the result, it would be nice to pass a timestamp to the is_cached() method in order to test whether the cache is newer than my news in the database. So I only have to fetch the timestamp of the latest news instead of running the template all the time: // $time contains a unix timestamp of the latest news if (!$smarty->is_cached($tpl, $cache_id, $time)) { $smarty->clear_cache($tpl, $cache_id); // fetch and assign news from database } $smarty->display($tpl, $cache_id); -- Ferdinand Beyer <fbeyer@clickhand.de>

« previous php.smarty.general (#8432) next »