mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #4831 -- Added an "add" cache key method, for parity with memcached's
API. This works for all cache backends. Patch from Matt McClanahan. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6572 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
6
tests/regressiontests/cache/tests.py
vendored
6
tests/regressiontests/cache/tests.py
vendored
@@ -19,6 +19,12 @@ class Cache(unittest.TestCase):
|
||||
cache.set("key", "value")
|
||||
self.assertEqual(cache.get("key"), "value")
|
||||
|
||||
def test_add(self):
|
||||
# test add (only add if key isn't already in cache)
|
||||
cache.add("addkey1", "value")
|
||||
cache.add("addkey1", "newvalue")
|
||||
self.assertEqual(cache.get("addkey1"), "value")
|
||||
|
||||
def test_non_existent(self):
|
||||
# get with non-existent keys
|
||||
self.assertEqual(cache.get("does_not_exist"), None)
|
||||
|
||||
Reference in New Issue
Block a user