Django cache provides cache.incr() to atomically increase integer values.
Step 2: Compare with other options
value = cache.get('counter') + 1; cache.set('counter', value) is not atomic and can cause race conditions; cache.increment('counter') is invalid; cache.add('counter', 1) adds key only if missing.
Final Answer:
cache.incr('counter') -> Option D
Quick Check:
Use cache.incr() for atomic increments [OK]
Quick Trick:Use cache.incr() to safely increment integers [OK]
Common Mistakes:
MISTAKES
Manually incrementing without atomicity
Using non-existent increment() method
Using cache.add() which only adds if missing
Master "Caching" in Django
9 interactive learning modes - each teaches the same concept differently