On 17 May 2011 11:15, Tom Evans <tevans...@googlemail.com> wrote:

> On Tue, May 17, 2011 at 11:03 AM, Malcolm Box <malcolm....@gmail.com>
> wrote:
> > That looks like a bug in Django. I suggest you file a ticket.
> >
> > The fix would be to compare timeout to None
> >
>
> A ticket has already been submitted about this. The issue is that
> although memcache allows setting 'infinite' timeouts (its not
> infinite, it just pushes out old data on LRU basis), other backends do
> not.
>
> http://code.djangoproject.com/ticket/9595
>
>
Looking at this ticket, the argument is that this would be inconsistent with
other backends, and that therefore there should be another "special" way to
mean infinite timeout.

However, current behaviour isn't consistent: behaviour on passing 0 as
timeout to cache.set() is:

- filecache - deletes the key (sets expiry to now, so that the key will be
deleted on get)
- memcached - sets the expiry time to the default timeout
- locmem - deletes the key (sets expiry time to now).

Changing the memcached backend to make 0 = infinite cache doesn't strike me
as worse than having memcache have 0 = default timeout, and it means that
the useful memcache behaviour of infinite timeout is available.

I'd propose that the behaviour is modified to:

timeout = None : set default timeout on all backends
timeout = 0 : set "longest possible" expiry on all backends. If people are
already relying on 0 = delete on some backends their code already won't work
on memcache.  Alternatively, if this is felt to be a too-big incompatibility
then simply document 0 as special with backend dependant behaviour (the
current situation), and change memcache behaviour to be infinite timeout.

Cheers,

Malcolm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to