AI-assisted engineering/AI-collaboration build

Fix MemoCache so it honors its contract

AI-collaboration buildMedium40 min

Build with an assistant that errs on purpose. Catch what it gets wrong before the hidden tests do.

Your task

Fix MemoCache so it honors its contract. The assistant may help, and it may also be wrong.

  • put(key, value) stores value; the entry lives for ttl seconds from now
  • get(key) returns the value while the entry is live, None once expired
  • an entry is expired the instant now() reaches its expiry time
  • putting an existing key refreshes both the value and the expiry
  • a get that finds an expired entry evicts it from memory

Hidden tests run at submit. Your prompts, runs, and edits are the trace the critique reads.