Spec a memoize decorator with size and expiry
Your task
Your Python service calls a slow pricing function, quote(sku, region, currency="USD"), thousands of times a minute with the same arguments. Prices change at most every few minutes, so a short cache is safe. An agent will write a decorator, @memoize(maxsize, ttl), for it and for other pure functions.
Write the spec you would hand the agent.
What you know:
- the service is long-running and multi-threaded
- callers pass
regionandcurrencyboth by position and by keyword - some callers pass a list of SKUs, which cannot be a dictionary key
- Python 3.12, standard library only
Then, in a few sentences: what does "add a caching decorator with a TTL" get wrong?