Serve hot data in under a millisecond
Check MemoryStore before you query the database, and write the result to the cache with a TTL whenever the key is missing. Until the TTL expires, your application serves each later request from the cached copy in memory.
Impact
The sample looks up the EUR/USD quote for Pelagos Trading in MemoryStore and calls computeQuoteSnapshot only when GET returns no value. Because the SET command stores the snapshot for five seconds, your application answers every request in that window from the cached quote.
Prompt for a coding agent: Cache the EUR/USD quote for five seconds, and compute it again on a cache miss.
Select a file to view its contents
