[development] minimum cache lifetime {was: Should I submit a new module?}
Jeremy Andrews
jeremy at kerneltrap.org
Wed Jun 6 09:27:21 UTC 2007
On Wed, 06 Jun 2007 07:34:49 +0200
Stefan Borchert <stefan at borchert.cc> wrote:
> Steven Jones schrieb:
> > Because "Minimum cache lifetime" keeps things in the
> > cache for longer,
> Errm, no.
> <quote from admin/settings/performance>
> "The minimum cache lifetime is the minimum amount of time
> that will go by before the cache is emptied and recreated."
> </quote>
> If you set it to "10 min" the cache is cleared every ten
> minutes (on the next page request).
That is not correct. The minimum cache lifetime enforces
exactly what the name says: a minimum cache lifetime. It
simply ensures that the cache will not be flushed more
frequently than the configured value.
It does not enforce a maximum cache lifetime. Setting the
minimum cache lifetime to 10 minutes does not cause the cache
to be flushed every 10 minutes -- it means that there is a 10
minute delay between when Drupal requests that the cache be
flushed and when it is actually flushed. (The idea being that
if the cache is flushed each time a comment is posted, on a
busy site like drupal.org this can lead to the cache being
flushed too often to actually be used in serving pages to
anonymous users.)
-----
Digression about the current implementation, and how it could
be easily improved:
-----
I think the current implementation is not quite right.
Currently it works as follows:
Using your example of a minimum cache lifetime of "10 min":
1) the cache is flushed at 01:00:00
2) another cache flush event is requested at 01:01:14 (for
example, a comment is posted)
3) the cache is not actually flushed until 01:11:14, ten
minutes after the second cache flush request.
That is, the current logic simply ads a delay between when
the cache flush request was made, and when it is actually
executed. It seems instead it would be better to track the
last time the cache wash flushed, and simply be sure that the
minimum cache lifetime has passed before flushing again. In
that case, it would work as follows:
1) the cache is flushed at 01:00:00
2) another cache flush event is requested at 01:01:14 (for
example, a comment is posted)
3) the cache is not actually flushed until 01:10:00, ten
minutes after the last time the cache was flushed.
(In a more exaggerated example to illustrate why I think the
current implementation is wrong:
1) the cache is flushed at 01:00:00
2) another cache flush event is requested at 02:45:10
3) the cache is not actually flushed until 02:55:10 -- this
added 10 minute delay is silly at this point as the
cache already lived 2 hours and 45 minutes. It should
instead be immediately flushed at that point.)
Cheers,
-Jeremy
More information about the development
mailing list