diff -r 00e4e4b60c7f django/core/cache/backends/memcached.py
a
|
b
|
|
17 | 17 | self._cache = memcache.Client(server.split(';')) |
18 | 18 | |
19 | 19 | def add(self, key, value, timeout=0): |
20 | | return self._cache.add(key.encode('ascii', 'ignore'), value, timeout or self.default_timeout) |
| 20 | return self._cache.add(smart_str(key.replace(" ", "_")), value, timeout or self.default_timeout) |
21 | 21 | |
22 | 22 | def get(self, key, default=None): |
23 | | val = self._cache.get(smart_str(key)) |
| 23 | val = self._cache.get(smart_str(key.replace(" ", "_"))) |
24 | 24 | if val is None: |
25 | 25 | return default |
26 | 26 | else: |
… |
… |
|
32 | 32 | def set(self, key, value, timeout=0): |
33 | 33 | if isinstance(value, unicode): |
34 | 34 | value = value.encode('utf-8') |
35 | | self._cache.set(smart_str(key), value, timeout or self.default_timeout) |
| 35 | self._cache.set(smart_str(key.replace(" ", "_")), value, timeout or self.default_timeout) |
36 | 36 | |
37 | 37 | def delete(self, key): |
38 | | self._cache.delete(smart_str(key)) |
| 38 | self._cache.delete(smart_str(key.replace(" ", "_"))) |
39 | 39 | |
40 | 40 | def get_many(self, keys): |
41 | | return self._cache.get_multi(map(smart_str,keys)) |
| 41 | return self._cache.get_multi([smart_str(k.replace(" ", "_")) for k in keys]) |
42 | 42 | |
43 | 43 | def close(self, **kwargs): |
44 | 44 | self._cache.disconnect_all() |