# Agent A -- Monday: "speed up the user lookup endpoint"
# Generated diff hunk (annotated for the demo).

import redis

_cache = redis.Redis(host="localhost", port=6379, decode_responses=True)

def get_user(user_id: str) -> dict:
    cached = _cache.get(f"user:{user_id}")
    if cached:
        return json.loads(cached)
    user = _load_user_from_disk(user_id)
    _cache.setex(f"user:{user_id}", 300, json.dumps(user))
    return user
