Complete the code to set the cache expiration time to 60 seconds.
cache.set('user_data', data, expire=[1])
The expiration time is set in seconds. 60 means the cache will expire after one minute.
Complete the code to check if the cached data has expired before returning it.
if cache.get('user_data') is not [1]: return cache.get('user_data')
When cache.get returns None, it means the data is not in cache or expired.
Fix the error in the code to correctly update the cache with new data and expiration.
cache.[1]('user_data', new_data, expire=120)
The correct method to store data with expiration is 'set'.
Fill both blanks to create a cache dictionary comprehension that stores word lengths only for words longer than 3 characters.
cache_data = {word: [1] for word in words if len(word) [2] 3}We want the length of each word (len(word)) and only include words longer than 3 characters (len(word) > 3).
Fill all three blanks to create a cache dictionary comprehension that stores uppercase words as keys and their lengths as values, only if length is greater than 4.
cache_data = { [1]: [2] for word in words if len(word) [3] 4 }The keys are uppercase words (word.upper()), values are their lengths (len(word)), and we filter words longer than 4 characters (len(word) > 4).