Open
Description
Have you considered supporting different cache strategies?
Now the cache is hard-coded in the library, but providing a cache interface (or using some standard, existing one) that people can implement and then plug in their own cache might be useful. Some ideas of what could be handy:
- No cache. In a multi-user app with data being frequently modified, one might want to fetch fresh data from the backend whenever a page is displayed.
- Time-to-live setting. Some data might have logical lifespan, after which it could be automatically expired and thus saving us clearing the cache imperatively. The timeout might be set on the global level, per-wrapped fn, or per call.
Alternatively, it might be beneficial to use some existing, proven library for caching (e.g. https://www.npmjs.com/package/lru-cache ?) instead of implementing own solution, and allowing the users to configure it.