Caching ఖరీదైన ఆపరేషన్ల (DB queries, computations, external API calls) ఫలితాలను సংગ్రహిస్తుంది, తద్వారా పదేపదే అభ్యర్థనలు చేసిన పనిని పునరావృత్తి చేయకుండా వేగంగా సేవ చేయవచ్చు. ఇది API కోసం అత్యధిక-ప్రభావం కలిగిన పనితీరు ఆప్టిమైజేషన్లలో ఒకటి.
In-memory caching (అత్యంత వేగవంతమైన, single-instance)
cache = ();
() {
(cache.(id)) cache.(id);
user = db.(id);
cache.(id, user);
user;
}
