      def test_memcached_deletes_key_on_failed_set(self):
          # By default memcached allows objects up to 1MB. For the cache_db session
          # backend to always use the current session, memcached needs to delete
          # the old key if it fails to set.
          # pylibmc doesn't seem to have SERVER_MAX_VALUE_LENGTH as far as I can
          # tell from a quick check of its source code. This is falling back to
          # the default value exposed by python-memcached on my system.
          max_value_length = getattr(cache._lib, 'SERVER_MAX_VALUE_LENGTH', 1048576)
  
          cache.set('small_value', 'a')
          self.assertEqual(cache.get('small_value'), 'a')
  
          large_value = 'a' * (max_value_length + 1)
 
</s> remove             # Some clients (e.g. pylibmc) raise when the value is too large,
            # while others (e.g. python-memcached) intentionally return True
            # indicating success. This test is primarily checking that the key
            # was deleted, so the return/exception behavior for the set()
            # itself is not important.
 </s> add             # Most clients (e.g. pymemcache or pylibmc) raise when the value is
            # too large. This test is primarily checking that the key was
            # deleted, so the return/exception behavior for the set() itself is
            # not important. </s> remove     # Some caches -- python-memcached in particular -- need to do a cleanup at the
    # end of a request cycle. If not implemented in a particular backend
    # cache.close is a no-op
 </s> add     # Some caches need to do a cleanup at the end of a request cycle. If not
    # implemented in a particular backend cache.close() is a no-op. </s> remove   ``django.core.cache.backends.memcached.MemcachedCache``,
  ``django.core.cache.backends.memcached.PyLibMCCache``, or
  ``django.core.cache.backends.memcached.PyMemcacheCache`` (depending on your
 </s> add   ``django.core.cache.backends.memcached.PyMemcacheCache`` or
  ``django.core.cache.backends.memcached.PyLibMCCache`` (depending on your
        max_value_length = 2 ** 20
      def test_memcached_deletes_key_on_failed_set(self):
          # By default memcached allows objects up to 1MB. For the cache_db session
          # backend to always use the current session, memcached needs to delete
          # the old key if it fails to set.
        max_value_length = 2 ** 20
        max_value_length = 2 ** 20
        max_value_length = 2 ** 20
        max_value_length = 2 ** 20
  
          cache.set('small_value', 'a')
          self.assertEqual(cache.get('small_value'), 'a')
  
          large_value = 'a' * (max_value_length + 1)
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Fixed #32193 -- Deprecated MemcachedCache. 
tests/cache/tests.py