By: Mr.Plugin
Date: 2005-02-03
Time: 16:38
|
Cache + poor DB availability
Hi.
I need to fetch data from a remote DB server, which could be not available from time to time, due to maintainance tasks, downtimes or connectivity issues. When the server is unreachable for whatever reason, my pages just die with a "service not available, try again later" message. I wonder if there is a way to use the cached contents (even if they're outdated, i dont care), instead of displaying nothing at all when the cache expires. Can you help me to figure out a workaround?.
Thanks in advance and congrats for your awesome job.
|
By: Skrol29
Date: 2005-02-03
Time: 18:40
|
Re: Cache + poor DB availability
Hi,
Here is a solution:
// Try to connect
$conn = ...
// load cache or schedule saving
$cache_id = 'saveincase';
if ($conn===false) {
if (!$TBS->CacheAction($cache_id,TBS_CACHELOAD)) {
echo 'Connection failed, no cache available.';
}
exit;
} else {
$TBS->CacheAction($cache_id,TBS_CACHEONSHOW);
}
// Normal template process
$TBS->LoadTemplate(...);
...
$TBS->Show();
|
|