For one of my projects I needed memoizer, that would be both fast and would work with any type of input arguments. Other projects demanded other common functionalities, so it's result of real world needs I approached in last months. To make it complete in latest stage I added max and maxAge options (lru-cache inspiration)
- Works with any type of function arguments – no serialization is needed
- Works with any length of function arguments. Length can be set as fixed or dynamic.
- One of the fastest available solutions (when talking about plain simple case it's slightly slower than basic underscore implementation and about 3 x faster than lru-cache)
- Support for asynchronous functions
- Optional primitive mode which assures fast performance when arguments are conversible to strings.
- Can be configured for methods (when `this` counts in)
- Cache can be cleared manually or after specified timeout
- Cache size can be limited
- Optionally accepts resolvers that normalize function arguments before passing them to underlying function.
- Optional reference counter mode, that allows more sophisticated cache management
- Profile tool that provides valuable usage statistics
- Covered by over 500 unit tests
I use it all over the place now. Let me know what you think, any feedback highly welcome