Caching stores the results of expensive operations (DB queries, computations, external API calls) so repeated requests can be served fast without redoing the work. It's one of the highest-impact performance optimizations for an API.
In-memory caching (fastest, single-instance)
cache = ();
() {
(cache.(id)) cache.(id);
user = db.(id);
cache.(id, user);
user;
}
