          cache.set("key", "value")
          self.assertEqual(cache.get("key"), "value")
  
      def test_non_existent(self):
          # get with non-existent keys
          self.assertEqual(cache.get("does_not_exist"), None)
          self.assertEqual(cache.get("does_not_exist", "bang!"), "bang!")
  
 
</s> remove                 cursor.execute("INSERT INTO %s (cache_key, value, expires) VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)])
 </s> add                 if mode == 'add':
                    cursor.execute("INSERT INTO %s (cache_key, value, expires) VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)]) </s> remove             if cursor.fetchone():
 </s> add             if mode == 'set' and cursor.fetchone():
    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")

          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)
          self.assertEqual(cache.get("does_not_exist", "bang!"), "bang!")
  
keep keep add keep keep keep keep keep
 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 
tests/regressiontests/cache/tests.py