dns-cached-resolve icon indicating copy to clipboard operation
dns-cached-resolve copied to clipboard

Custom implementation of DNS Cache

Open justinm opened this issue 6 years ago • 1 comments

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.

justinm avatar Mar 05 '19 23:03 justinm

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.

OlliV avatar Mar 07 '19 11:03 OlliV