{
  "id": "cb-06",
  "name": "ttl_cache",
  "passed": true,
  "grade_detail": "all asserts passed",
  "wall_s": 61.1,
  "usage": {
    "completion_tokens": 1500,
    "prompt_tokens": 105,
    "total_tokens": 1605,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "answer": "```python\nclass TTLCache:\n    \"\"\"A cache in which entries expire after a caller-supplied TTL.\n\n    Expiry is computed against an injectable clock: the `now` argument\n    is a callable returning the current time as a float number of\n    seconds. All expiry decisions go through that callable, so the\n    cache itself never touches time.time().\n    \"\"\"\n\n    def __init__(self, now):\n        \"\"\"\n        Args:\n            now: Callable returning the current time as a float of\n                 seconds. Used for every expiry computation.\n        \"\"\"\n        self._now = now\n        self._entries = {}  # key -> (value, expiry_time)\n\n    def put(self, key, value, ttl):\n        \"\"\"Store `value` under `key`, valid for `ttl` seconds from now.\"\"\"\n        self._entries[key] = (value, self._now() + ttl)\n\n    def get(self, key):\n        \"\"\"Return the value for `key`, or None if it is absent or expired.\"\"\"\n        entry = self._entries.get(key)\n        if entry is None:\n            return None\n        value, expiry = entry\n        if self._now() >= expiry:\n            # Lazily evict expired entries.\n            del self._entries[key]\n            return None\n        return value\n```",
  "finish_reason": "stop"
}