MCPcopy
hub / github.com/django/django / add

Method add

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

Set a value in the cache if the key does not already exist. If timeout is given, use that timeout for the key; otherwise use the default cache timeout. Return True if the value was stored, False otherwise.

(self, key, value, timeout=DEFAULT_TIMEOUT, version=None)

Source from the content-addressed store, hash-verified

125 return key
126
127 def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
128 """
129 Set a value in the cache if the key does not already exist. If
130 timeout is given, use that timeout for the key; otherwise use the
131 default cache timeout.
132
133 Return True if the value was stored, False otherwise.
134 """
135 raise NotImplementedError(
136 "subclasses of BaseCache must provide an add() method"
137 )
138
139 async def aadd(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
140 return await sync_to_async(self.add, thread_sensitive=True)(

Callers 10

get_or_setMethod · 0.95
sort_dependenciesFunction · 0.45
innerMethod · 0.45
handleMethod · 0.45
show_listMethod · 0.45
show_planMethod · 0.45
handle_inspectionMethod · 0.45
save_objMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected