Opened 13 years ago

Last modified 11 years ago

#16858 closed Bug

incr() on locmem cache resets the expiry time — at Version 1

Reported by: Malcolm Box Owned by: nobody
Component: Core (Cache system) Version: 1.5-rc-1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Alex Gaynor)

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.

Change History (1)

comment:1 by Alex Gaynor, 13 years ago

Description: modified (diff)

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?

Note: See TracTickets for help on using tickets.
Back to Top