Suggestion
| From: | Norbert Röcher | Date: | Fri, 12 Apr 2002 09:46:11 +0000 |
| Subject: | Suggestion | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-3663@lists.php.net to get a copy of this message | ||
Hi all,
currently a cached file contains the timestamp of when it of was
generated.
Problem: I use "if ($this->is_cached)" to intercept useless
db-operations (what a surprise :-D) for blocks included within a
template. Now i want to support different expiration times for the
included blocks, and want to set $cache_lifetime to the minimum value
of these expiration times. So the whole site will expire, when one
block expires. Normally not a problem, but to get the expiration times,
i've got to read them from the db, because $cache_lifetime has to be
set to its value BEFORE checking the cached file. And in this situation
"$this->is_cached" is absolutely useless, because it doesn't prevent
from unwanted db-operations.
I think it would make more sense, when cached files contain the
timestamp of expiration. Should look like kind of this:
write cache_info:
cachedFile_timestamp = time() + cache_lifetime;
read cache_info:
if (cachedFile_timestamp > time()){
is_cached = true;
}
The benefit would be to be able to set $cache_lifetime also AFTER the
check for cache_expiration. Allows much more dynamic...
What do you think?
Regards,
Norbert