Open justinm opened 5 years ago
That sounds like a really good idea. I have personally pursued for our internal libraries to accept custom cache object(s) to unblock use cases that needs something special from the caching. I'd go with the api of lru-cache
. Perhaps injecting a cache could be even required so you don't need to install lru-cache
where you don't need it.
I'd like to be able to pass a custom cache implementation ie
{ get: (k) => {}, set: (k, v) => {} }
. There's a few reasons one would want to do this:A) Utilize centralized caching, like Redis. B) Implement custom metrics for cache hits/misses.
I recognize this would require not only changing this library, but also @zeit/dns-cached-resolve, as it does not accept a custom cache implementation.
If this is a feature you'd consider for inclusion, I'd like to work on a prototype and submit it back to you via PR.