Caching with Memoization and the Singleton Pattern

notes

Reading this article on memorization (opens in a new tab) which is the best explanation I've come across.

So it's caching using a function or object to store expensive computations in memory.

I think we could use a Singleton (opens in a new tab) for this right?

UPDATED

After doing further research, a Singleton might not be the best pattern (opens in a new tab) to use for Memoizing a function.

Also, a really great look at memoization and its performance metrics (opens in a new tab) by Addy Osmani.

© tiff