Used dict comprehensions in BaseMemcachedCache.get_many() and set_many() for better readability.
This commit is contained in:
parent
179b247e07
commit
3633c2a045
|
@ -89,11 +89,8 @@ class BaseMemcachedCache(BaseCache):
|
||||||
new_keys = [self.make_key(x, version=version) for x in keys]
|
new_keys = [self.make_key(x, version=version) for x in keys]
|
||||||
ret = self._cache.get_multi(new_keys)
|
ret = self._cache.get_multi(new_keys)
|
||||||
if ret:
|
if ret:
|
||||||
_ = {}
|
|
||||||
m = dict(zip(new_keys, keys))
|
m = dict(zip(new_keys, keys))
|
||||||
for k, v in ret.items():
|
return {m[k]: v for k, v in ret.items()}
|
||||||
_[m[k]] = v
|
|
||||||
ret = _
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def close(self, **kwargs):
|
def close(self, **kwargs):
|
||||||
|
@ -137,10 +134,10 @@ class BaseMemcachedCache(BaseCache):
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None):
|
def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None):
|
||||||
safe_data = {}
|
safe_data = {
|
||||||
for key, value in data.items():
|
self.make_key(key, version=version): value
|
||||||
key = self.make_key(key, version=version)
|
for key, value in data.items()
|
||||||
safe_data[key] = value
|
}
|
||||||
self._cache.set_multi(safe_data, self.get_backend_timeout(timeout))
|
self._cache.set_multi(safe_data, self.get_backend_timeout(timeout))
|
||||||
|
|
||||||
def delete_many(self, keys, version=None):
|
def delete_many(self, keys, version=None):
|
||||||
|
|
Loading…
Reference in New Issue