[PATCH 1/2] Skip cache slot when time-to-live is zero

Lukas Fleischer cgit at cryptocrack.de
Thu Feb 6 22:07:51 CET 2014


On Thu, 06 Feb 2014 at 20:52:46, Jason A. Donenfeld wrote:
> On Wed, Feb 5, 2014 at 10:46 AM, Lukas Fleischer <cgit at cryptocrack.de>wrote:
> >
> >         /* If the cache is disabled, just generate the content */
> > -       if (size <= 0) {
> > +       if (size <= 0 || ttl == 0) {
> >                 fn();
> >                 return 0;
> >         }
> 
> 
> Apparently we already special case ttl for < 0:
> 
> /* Check if the slot has expired */
> static int is_expired(struct cache_slot *slot)
> {
>         if (slot->ttl < 0)
>                 return 0;
>         else
>                 return slot->cache_st.st_mtime + slot->ttl * 60 <
> time(NULL);
> }
> 
> What should our behavior be for consistency?

This is different. -1 means "never expire". 0 means "always expire". We
cannot add the 0 special case to is_expired(), though, because that
would mean we would update and write the cache file to disk on every
request which seems to be a bad idea (actually, that is what already
happens now without having a special case).


More information about the CGit mailing list