Re: [SMARTY] a tiny thing that worries me
| From: | Monte Ohrt | Date: | Thu, 05 Dec 2002 16:45:55 +0000 |
| Subject: | Re: [SMARTY] a tiny thing that worries me | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6657@lists.php.net to get a copy of this message | ||
_read_cache_file() does store the results of a check.
static $content_cache = array();
if (isset($content_cache["$tpl_file,$cache_id,$compile_id"])) {
list($results, $this->_cache_info) =
$content_cache["$tpl_file,$cache_id,$compile_id"];
return true;
}
Monte
On Thu, 2002-12-05 at 10:31, Rasmus Schultz wrote:
> I took a look at the code, and as far as I can see, I'm right - the
> function _read_cache_file, which if used to determine if a cache
> file needs to regenerate or not, is used by both fetch (which is
> called by display) and by is_cached individually, and there does
> not seem to be any measures taken in _read_cache_file to prevent
> returning different results during one session ... in fact, wouldn't
> the code be faster if the test result was stored by _read_cache_file?
> so that when you called is_cached and then display/fetch, the test
> would only be performed once? ... would the programmers comment on
> this, please? :)
>
> --- At 2002-12-04, 22:18:00, Rasmus Schultz <m@mindplay.dk> wrote:
>
> >there's one tiny thing that's been nagging at my mind
> >for some time now - about caching ... take this example:
> >
> >if (!$smarty->is_cached("my.tpl")) {
> > $smarty->assign...
> > etc.
> >}
> >$smarty->display("my.tpl");
> >
> >now I'm checking first, if the page is cached - and so
> >I can't help but wonder, what happens if the cache expires
> >JUST after I perform the first check? the function would
> >return true, and consequently I would not perform database
> >operations or assign variables for the template, which
> >when display is called just afterwards, would result in
> >a bad page/missing content.
> >
> >I know that the odds of this happening are minimal, but
> >the possibility is there, and it's this sort of thing that
> >can cause tiny, unpredictable errors in large systems.
> >
> >I actually presume that is_cached remembers it's result
> >when it's first called, so that when the display function
> >has to check if the page is called, it gets the result
> >from the previous is_cached check? I mean, that's how it
> >ought to work, but I'd just like to be sure ... any of
> >the programmers would like to comment on this?
> >
> >I'm probably just being paranoid :)
> >
> >
> >
> >
> >--
> >Smarty General Mailing List (http://smarty.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Monte Ohrt <monte@ispi.net>