Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22495 closed Bug (fixed)

Locmem cache.add() fails with infinitely cached objects

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

Description

Simple test case:

from django.core.cache.backends.locmem import LocMemCache

c2 = LocMemCache("locmem", {})

In [18]: c2.set('test', 'locked', timeout=None)

In [19]: c2.add('test', 'new')
Out[19]: True

In [20]: c2.get('test')
Out[20]: 'new'

Since a timeout of None now means "cache forever", the cache.add() should not succeed and should return False.

Memcached behaviour for comparison:

In [24]: from django.core.cache.backends.memcached import PyLibMCCache

In [25]: memcache = PyLibMCCache(server="localhost:11211", params={})

In [26]: memcache.set('test', 'locked', timeout=None)

In [27]: memcache.add('test', 'new')
Out[27]: False

Change History (6)

comment:1 by Malcolm Box, 10 years ago

Owner: changed from nobody to Malcolm Box
Status: newassigned

comment:3 by Malcolm Box, 10 years ago

Has patch: set

comment:4 by Claude Paroz, 10 years ago

Triage Stage: UnreviewedAccepted
Version: 1.61.7-beta-2

comment:5 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In af5f688392b7fc110d06660ff91f79c742ae751d:

Fixed #22495 -- Locmem cache.add() failed with infinite timeouts

cache.add() incorrectly succeeded when there was an existing key
with an infinite (None) timeout.

comment:6 by Claude Paroz <claude@…>, 10 years ago

In 07235aec9d0853b4fa58629c572912786b6270c9:

[1.7.x] Fixed #22495 -- Locmem cache.add() failed with infinite timeouts

cache.add() incorrectly succeeded when there was an existing key
with an infinite (None) timeout.
Backport of af5f688392 from master.

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