Browse Source

Refs #20892 -- Removed support for passing pylibmc behavior settings as top-level attributes of CACHES['OPTIONS'].

Per deprecation timeline.
Tim Graham 7 years ago
parent
commit
e47b56d791
4 changed files with 3 additions and 47 deletions
  1. 0 21
      django/core/cache/backends/memcached.py
  2. 3 0
      docs/releases/2.1.txt
  3. 0 8
      docs/topics/cache.txt
  4. 0 18
      tests/cache/tests.py

+ 0 - 21
django/core/cache/backends/memcached.py

@@ -3,10 +3,8 @@
 import pickle
 import re
 import time
-import warnings
 
 from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
-from django.utils.deprecation import RemovedInDjango21Warning
 from django.utils.functional import cached_property
 
 
@@ -171,25 +169,6 @@ class PyLibMCCache(BaseMemcachedCache):
         import pylibmc
         super().__init__(server, params, library=pylibmc, value_not_found_exception=pylibmc.NotFound)
 
-        # The contents of `OPTIONS` was formerly only used to set the behaviors
-        # attribute, but is now passed directly to the Client constructor. As such,
-        # any options that don't match a valid keyword argument are removed and set
-        # under the `behaviors` key instead, to maintain backwards compatibility.
-        legacy_behaviors = {}
-        for option in list(self._options):
-            if option not in ('behaviors', 'binary', 'username', 'password'):
-                warnings.warn(
-                    "Specifying pylibmc cache behaviors as a top-level property "
-                    "within `OPTIONS` is deprecated. Move `%s` into a dict named "
-                    "`behaviors` inside `OPTIONS` instead." % option,
-                    RemovedInDjango21Warning,
-                    stacklevel=2,
-                )
-                legacy_behaviors[option] = self._options.pop(option)
-
-        if legacy_behaviors:
-            self._options.setdefault('behaviors', {}).update(legacy_behaviors)
-
     @cached_property
     def _cache(self):
         return self._lib.Client(self._servers, **self._options)

+ 3 - 0
docs/releases/2.1.txt

@@ -236,3 +236,6 @@ how to remove usage of these features.
 * ``django.test.runner.setup_databases()`` is removed.
 
 * ``django.utils.translation.string_concat()`` is removed.
+
+* ``django.core.cache.backends.memcached.PyLibMCCache`` no longer supports
+  passing ``pylibmc`` behavior settings as top-level attributes of ``OPTIONS``.

+ 0 - 8
docs/topics/cache.txt

@@ -479,14 +479,6 @@ the binary protocol, SASL authentication, and the ``ketama`` behavior mode::
         }
     }
 
-.. versionchanged:: 1.11
-
-    Memcached backends can now be configured using ``OPTIONS``.
-
-    In older versions, you could pass ``pylibmc`` behavior settings directly
-    inside ``OPTIONS``. This is deprecated in favor of setting them under a
-    ``behaviors`` key within ``OPTIONS`` instead.
-
 .. _the-per-site-cache:
 
 The per-site cache

+ 0 - 18
tests/cache/tests.py

@@ -1308,24 +1308,6 @@ class PyLibMCCacheTests(BaseMemcachedTests, TestCase):
         self.assertTrue(cache._cache.binary)
         self.assertEqual(cache._cache.behaviors['tcp_nodelay'], int(True))
 
-    @override_settings(CACHES=caches_setting_for_tests(
-        base=PyLibMCCache_params,
-        exclude=memcached_excluded_caches,
-        OPTIONS={'tcp_nodelay': True},
-    ))
-    def test_pylibmc_legacy_options(self):
-        deprecation_message = (
-            "Specifying pylibmc cache behaviors as a top-level property "
-            "within `OPTIONS` is deprecated. Move `tcp_nodelay` into a dict named "
-            "`behaviors` inside `OPTIONS` instead."
-        )
-        with warnings.catch_warnings(record=True) as warns:
-            warnings.simplefilter("always")
-            self.assertEqual(cache._cache.behaviors['tcp_nodelay'], int(True))
-        self.assertEqual(len(warns), 1)
-        self.assertIsInstance(warns[0].message, RemovedInDjango21Warning)
-        self.assertEqual(str(warns[0].message), deprecation_message)
-
 
 @override_settings(CACHES=caches_setting_for_tests(
     BACKEND='django.core.cache.backends.filebased.FileBasedCache',