Complete the code to show where cached data is stored.
cache = [1]()Caching stores data in in-memory to allow faster access than disk or network.
Complete the code to check if data is in cache before fetching from source.
if key [1] cache: return cache[key]
We check if the key is in the cache to use cached data and reduce latency.
Fix the error in the code that updates the cache after fetching data.
data = fetch_from_source(key)
cache[[1]] = dataThe cache key must be the key used to fetch data, not the value or data itself.
Fill both blanks to complete the code that returns cached data or fetches and caches it.
if [1] in cache: return cache[[2]]
Both blanks must be the key to check and retrieve the cached data correctly.
Fill all three blanks to complete the caching logic with fetch and store.
if [1] not in cache: [2] = fetch_from_source([3]) cache[key] = data
Check if key is missing, fetch data into data, and use key to store it in cache.
