Input
Call get_user_profile("u1") twice within TTLOutput
Second call returns cached data without calling the upstream client again
Fix a production bug in a multi-file Python in-memory cache so that all provided tests pass. The repo implements `get_user_profile(user_id)`, which fetches from an upstream client and caches with a TTL. The cache curren...
profile_service.pyEditable startercache.pyEditable starterclient.pyEditable starterCall get_user_profile("u1") twice within TTLSecond call returns cached data without calling the upstream client again
p = get_user_profile("u1")
p["name"] = "Hacked"
Call get_user_profile("u1") again within TTLThe returned profile must not include "Hacked"
Caller mutation must not affect the cache.
How would you adapt this cache to be safe under concurrent access from multiple threads?