DEV Community

Discussion on: Oi You! Stop Requesting Everything: A Simple Guide to Memoization

Collapse
 
somedood profile image
Basti Ortiz

Thanks for this! As I was reading it, I suddenly thought of a way to optimize database calls from my Express app.

For each request, I query for the user object associated with the respective session. At scale, that would be very taxing on the database.

Instead, I could just memoize the database query so that I could refrain from contacting the database every time. Of course, I would have to be clever about it by employing a least-recently-used cache eviction strategy (lest my memory usage explodes).

👏👏👏

Collapse
 
jrdev_ profile image
Jr. Dev 👨🏾‍💻

Great example of how it can be used. I'm glad you found this useful 😁