NEW TICKET#39 · Currency conversion
A small cache for exchange rates
Hannah Cole · Senior Engineer
Opened today
“We call the exchange-rate service every time someone views a foreign-currency invoice, and we're hitting its limits. Keep a small cache of the most recently used currencies. When a currency is asked for: if it's cached, that's a hit, and it becomes the most recently used. If not, it's a miss: we fetch it and add it, and if the cache is now over capacity, drop the least recently used currency. To check the policy before we wire it up, cacheLog replays a list of requests and says hit or miss for each.”
YOUR PLAN
- 1Watch an example2 min
- 2Warm-up 11 min
- 3Warm-up 21 min
- 4Fix the ticket26 min
BY THE END YOU CAN
- Use a Map's key order as a recency list
- Move a key to the end with delete and set
- Find the oldest key with
keys().next()