A lookup that costs nothing
Inside your own process, a lookup costs nothing at all. No serialisation, no socket, no waiting. A read from a map in memory takes nanoseconds where a call to a shared cache takes tenths of a millisecond, roughly a thousand times the difference.
That gap is only worth having for data you fetch constantly. A feature flag read on every request, a currency table, a small lookup nobody edits. For anything larger the memory belongs to your application, and taking a gigabyte for cached data is a gigabyte your request handling no longer has.
Ten servers, ten caches
Now the part that catches people. Run ten servers and you have ten caches, and none of them knows about the others. Change a flag and the server you deployed to picks it up while the other nine carry on with the old value until their own copies expire. There is no delete that fixes all of them, because there is nothing they share.
The expiry is your tolerance for disagreement between your own servers. Thirty seconds means ten servers can hold different answers for thirty seconds. Fine for a feature flag. Not fine for anything a customer is paying for.
A real cache library beats a plain map. Caffeine and Guava give you a size limit, expiry, and eviction; a HashMap gives you an unbounded structure that grows until the process dies. That failure arrives in production, weeks later, as a memory problem nobody connects to the cache added in a hurry.
Worked example
Arjun cached his forty row currency table in each server's memory with a ten minute expiry. Forty rows, read on every checkout, changed once a day. It removed a Redis call from the hottest path in the system and nobody noticed it had happened, which is the correct outcome.
The same trick failed the following quarter. A colleague cached feature flags the same way, then used one to disable a broken payment provider during an incident. The flag flipped, one server obeyed immediately, and eleven others kept routing payments to the broken provider for the remaining nine minutes of the expiry.
The flags moved to Redis that week. Ten minutes of disagreement is nothing for an exchange rate and a long time during an outage.