MCPcopy
hub / github.com/django/django / incr

Method incr

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

Add delta to value in the cache. If the key does not exist, raise a ValueError exception.

(self, key, delta=1, version=None)

Source from the content-addressed store, hash-verified

273 )
274
275 def incr(self, key, delta=1, version=None):
276 """
277 Add delta to value in the cache. If the key does not exist, raise a
278 ValueError exception.
279 """
280 value = self.get(key, self._missing_key, version=version)
281 if value is self._missing_key:
282 raise ValueError("Key '%s' not found" % key)
283 new_value = value + delta
284 self.set(key, new_value, version=version)
285 return new_value
286
287 async def aincr(self, key, delta=1, version=None):
288 """See incr()."""

Callers 8

decrMethod · 0.95
test_incrMethod · 0.45
test_incrMethod · 0.45
test_decrMethod · 0.45
test_lru_incrMethod · 0.45

Calls 2

getMethod · 0.95
setMethod · 0.95

Tested by 7

test_incrMethod · 0.36
test_incrMethod · 0.36
test_decrMethod · 0.36
test_lru_incrMethod · 0.36