Re: [SMARTY] using expired cached files

From: Date: Fri, 12 Sep 2003 14:37:51 +0000
Subject: Re: [SMARTY] using expired cached files
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10197@lists.php.net to get a copy of this message
On Thu, Sep 11, 2003 at 02:57:21PM -0400, Marshall Sorenson wrote: > Hello, > > Does anyone know of a way to tell Smarty to use an expired cache file if an > error occured while trying to generate an updated cache file? > > For instance: > > if template not cached { > > do database query here > > if database query failed { > > smarty should use the recently expired cache file > > } else { > > process query results and assign to template > > } > > } > > $smarty->display('index.tpl'); you can try to modify $smarty->cache_lifetime before your call to is_cached(), maybe sth like: $smarty->caching = 1; $smarty->cache_lifetime = 3600; if (!smarty->is_cached()) { if database query failed { $cache_lifetime = -1; /* never expire */ # --- optional test if (!smarty->is_cached()) { // no cached version fatal error } else { // we use the expired cached template below } # --- end of optional test } else { // okay } } $smarty->display('index.tpl'); HTH messju > The way things are now I have to either die() on an error, or check for an > error and switch caching off. Both are ugly. > > -Marshall > ____________________________________ > > "If at first the idea is not absurd, > then there is no hope for it." > - Albert Einstein > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

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