MCPcopy
hub / github.com/django/django / set_many

Method set_many

django/core/cache/backends/base.py:319–333  ·  view source on GitHub ↗

Set a bunch of values in the cache at once from a dict of key/value pairs. For certain backends (memcached), this is much more efficient than calling set() multiple times. If timeout is given, use that timeout for the key; otherwise use the default cache tim

(self, data, timeout=DEFAULT_TIMEOUT, version=None)

Source from the content-addressed store, hash-verified

317 return self.has_key(key)
318
319 def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None):
320 """
321 Set a bunch of values in the cache at once from a dict of key/value
322 pairs. For certain backends (memcached), this is much more efficient
323 than calling set() multiple times.
324
325 If timeout is given, use that timeout for the key; otherwise use the
326 default cache timeout.
327
328 On backends that support it, return a list of keys that failed
329 insertion, or an empty list if all keys were inserted successfully.
330 """
331 for key, value in data.items():
332 self.set(key, value, timeout=timeout, version=version)
333 return []
334
335 async def aset_many(self, data, timeout=DEFAULT_TIMEOUT, version=None):
336 if self.set_many.__func__ is not BaseCache.set_many:

Callers 15

test_get_manyMethod · 0.45
test_deleteMethod · 0.45
test_set_manyMethod · 0.45
test_get_manyMethod · 0.45
test_deleteMethod · 0.45
test_unicodeMethod · 0.45
test_binary_stringMethod · 0.45
test_set_manyMethod · 0.45

Calls 2

setMethod · 0.95
itemsMethod · 0.45

Tested by 15

test_get_manyMethod · 0.36
test_deleteMethod · 0.36
test_set_manyMethod · 0.36
test_get_manyMethod · 0.36
test_deleteMethod · 0.36
test_unicodeMethod · 0.36
test_binary_stringMethod · 0.36
test_set_manyMethod · 0.36