{{{
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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22495>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => boxm
* needs_better_patch: => 0
* status: new => assigned
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/22495#comment:1>
Comment (by boxm):
Testcase and fix available here:
https://github.com/mbox/django/tree/ticket_22495
Pull request: https://github.com/django/django/pull/2603
--
Ticket URL: <https://code.djangoproject.com/ticket/22495#comment:2>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/22495#comment:3>
* version: 1.6 => 1.7-beta-2
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/22495#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"af5f688392b7fc110d06660ff91f79c742ae751d"]:
{{{
#!CommitTicketReference repository=""
revision="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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22495#comment:5>
Comment (by Claude Paroz <claude@…>):
In [changeset:"07235aec9d0853b4fa58629c572912786b6270c9"]:
{{{
#!CommitTicketReference repository=""
revision="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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22495#comment:6>