Bird
0
0

You want to cache a user's profile data for 10 minutes using Django's low-level cache API. Which code snippet correctly does this?

hard📝 Application Q15 of 15
Django - Caching
You want to cache a user's profile data for 10 minutes using Django's low-level cache API. Which code snippet correctly does this?
Acache.set('profile_1', user_profile, expire=600)
Bcache.set('profile_1', user_profile, timeout=600)
Ccache.save('profile_1', user_profile, timeout=600)
Dcache.set('profile_1', user_profile, time=600)
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct timeout argument

    The cache.set method uses the argument timeout to specify cache duration in seconds.
  2. Step 2: Check method and argument names

    Only cache.set('profile_1', user_profile, timeout=600) uses cache.set with timeout=600. Others use wrong method or argument names.
  3. Final Answer:

    cache.set('profile_1', user_profile, timeout=600) -> Option B
  4. Quick Check:

    Use cache.set with timeout for timed caching [OK]
Quick Trick: Use timeout parameter in cache.set for expiry [OK]
Common Mistakes:
MISTAKES
  • Using expire or time instead of timeout
  • Using cache.save which doesn't exist
  • Omitting timeout for temporary cache

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes