Complete the code to import the caching extension in Flask.
from flask_caching import [1]
The Flask-Caching extension provides the Cache class to enable caching in Flask apps.
Complete the code to initialize caching with a simple config.
app = Flask(__name__) app.config['CACHE_TYPE'] = [1] cache = Cache(app)
The 'simple' cache type uses in-memory caching suitable for development and testing.
Fix the error in the decorator to cache the response for 60 seconds.
@cache.[1](timeout=60) def get_data(): return 'Hello World'
The correct decorator to cache a view function is @cache.cached.
Fill both blanks to cache a function with a custom key prefix and 120 seconds timeout.
@cache.[1](timeout=[2], key_prefix='my_key') def fetch_data(): return {'data': 123}
Use @cache.cached with timeout=120 to cache the function with a custom key prefix.
Fill all three blanks to create a cache key dynamically using function arguments and cache the result.
def make_cache_key(*args, **kwargs): return f"user_[1]_[2]" @cache.[3](key_prefix=make_cache_key) def get_user_data(user_id, detail_level): return {'id': user_id, 'detail': detail_level}
The cache key uses args[0] (user_id) and args[1] (detail_level) to uniquely identify cached data. The @cache.memoize decorator caches functions with arguments.