#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 , 12 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 12 years ago
comment:3 by , 12 years ago
| Has patch: | set |
|---|
comment:4 by , 12 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Version: | 1.6 → 1.7-beta-2 |
comment:5 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Testcase and fix available here: https://github.com/mbox/django/tree/ticket_22495
Pull request: https://github.com/django/django/pull/2603