vercel / dns-cached-resolve

Caching DNS resolver
Apache License 2.0
41 stars 9 forks source link

Custom implementation of DNS Cache #21

Open justinm opened 5 years ago

justinm commented 5 years ago

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.

OlliV commented 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.