#16858: incr() on locmem cache resets the expiry time
-------------------------------------+-------------------------------------
               Reporter:  boxm       |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Milestone:             |      Component:  Core (Cache system)
                Version:  1.3        |       Severity:  Normal
             Resolution:             |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |    Needs tests:  0
    Needs documentation:  0          |  Easy pickings:  0
Patch needs improvement:  0          |
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
Changes (by Alex):

 * needs_docs:   => 0
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Old description:

> On the locmem cache backend, calling incr() causes the key's timeout
> value to be reset to the default for the cache.
>
> To reproduce:
> - setup the default cache to be locmem and with a timeout of 1 second
> >> cache.set('key', 10, 300)
> >> time.sleep(1)
> >> cache.get('key')
> 10
> >> cache.incr('key')
> >> time.sleep(1)
> >> cache.get('key')
> None
>
> The cache should still contain the key at the last line.
>
> The problem comes from the implementation of incr() in base.py which uses
> get() and set() to implement incr(). Since set() is called without a
> timeout, the cache default time is used.

New description:

 On the locmem cache backend, calling incr() causes the key's timeout value
 to be reset to the default for the cache.

 To reproduce:
 - setup the default cache to be locmem and with a timeout of 1 second
 {{{
 >> cache.set('key', 10, 300)
 >> time.sleep(1)
 >> cache.get('key')
 10
 >> cache.incr('key')
 >> time.sleep(1)
 >> cache.get('key')
 None
 }}}

 The cache should still contain the key at the last line.

 The problem comes from the implementation of incr() in base.py which uses
 get() and set() to implement incr(). Since set() is called without a
 timeout, the cache default time is used.

--

Comment:

 I'm assuming you consider this a bug, and would like it to not reset the
 expiry time ;)  What's the justification for that behavior, memcached does
 it?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16858#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to