summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Morley <emorley@mozilla.com>2016-08-31 18:15:22 +0100
committerTim Graham <timograham@gmail.com>2016-08-31 17:23:41 -0400
commitd8ef5b0e6501692b8b767ebccddc936f496d77e8 (patch)
tree9bc2aaa5e9acdf63d401e617727953570d7322dd
parentc8058dc241e7eea49ea6cf0e0abe7c4c38b79783 (diff)
downloaddjango-d8ef5b0e6501692b8b767ebccddc936f496d77e8.tar.gz
Fixed #27152 -- Supported comma delimiter in memcached LOCATION string.
-rw-r--r--django/core/cache/backends/memcached.py3
-rw-r--r--docs/releases/1.11.txt4
-rw-r--r--docs/topics/cache.txt9
-rw-r--r--tests/cache/tests.py1
4 files changed, 14 insertions, 3 deletions
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
index 2ca9f663d7..19671b4872 100644
--- a/django/core/cache/backends/memcached.py
+++ b/django/core/cache/backends/memcached.py
@@ -1,6 +1,7 @@
"Memcached cache backend"
import pickle
+import re
import time
import warnings
@@ -15,7 +16,7 @@ class BaseMemcachedCache(BaseCache):
def __init__(self, server, params, library, value_not_found_exception):
super(BaseMemcachedCache, self).__init__(params)
if isinstance(server, six.string_types):
- self._servers = server.split(';')
+ self._servers = re.split('[;,]', server)
else:
self._servers = server
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index d6a59c8ab9..3f232a56b8 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -173,6 +173,10 @@ Cache
control of client behavior. See the :ref:`cache arguments <cache_arguments>`
documentation for examples.
+* Memcached backends now allow defining multiple servers as a comma-delimited
+ string in :setting:`LOCATION <CACHES-LOCATION>`, for convenience with
+ third-party services that use such strings in environment variables.
+
CSRF
~~~~
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt
index 1730ef6294..2a48a66abe 100644
--- a/docs/topics/cache.txt
+++ b/docs/topics/cache.txt
@@ -128,8 +128,8 @@ multiple servers. This means you can run Memcached daemons on multiple
machines, and the program will treat the group of machines as a *single*
cache, without the need to duplicate cache values on each machine. To take
advantage of this feature, include all server addresses in
-:setting:`LOCATION <CACHES-LOCATION>`, either separated by semicolons or as
-a list.
+:setting:`LOCATION <CACHES-LOCATION>`, either as a semicolon or comma
+delimited string, or as a list.
In this example, the cache is shared over Memcached instances running on IP
address 172.19.26.240 and 172.19.26.242, both on port 11211::
@@ -168,6 +168,11 @@ permanent storage -- they're all intended to be solutions for caching, not
storage -- but we point this out here because memory-based caching is
particularly temporary.
+.. versionchanged:: 1.11
+
+ The :setting:`LOCATION <CACHES-LOCATION>` setting now supports defining
+ multiple servers as a comma-delimited string.
+
.. _database-caching:
Database caching
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index f31b3e1957..04c523e853 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -1160,6 +1160,7 @@ class BaseMemcachedTests(BaseCacheTests):
locations = [
['server1.tld', 'server2:11211'],
'server1.tld;server2:11211',
+ 'server1.tld,server2:11211',
]
for location in locations:
params = {'BACKEND': self.base_params['BACKEND'], 'LOCATION': location}