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

Reasoning behind 100 cache size default

Open ozyman42 opened this issue 1 year ago • 4 comments

I noticed the default cache size is 100. What's the rationale there? Shouldn't this be able to potentially hold thousands of entries without any notable impact on memory?

https://github.com/tcollinsworth/axios-cached-dns-resolve/blob/e5d90cf3e024f80e3e19a9e6a5555653f9000898/axios-cached-dns-resolve.js#L19

Separately, I'd like an ability to know whenever a cache eviction happens due to the cache filling up

ozyman42 avatar Nov 02 '23 23:11 ozyman42

I'm bringing up this issue because I am seeing a weird error where the refresh metric is always zero. Somehow refresh is never happening and I'm trying to determine if it's due to the cache having over 100 entries or maybe somehow the entry get evicted before the refresh code runs.

ozyman42 avatar Nov 02 '23 23:11 ozyman42

I set it based on typical needs of the many dozens of microservices I've worked with recently. They typically only communicate with a dozen or so services. It is configurable so if you need more, you can change it.

As for an eviction event, that seems like a reasonable request. Do you want to create a PR?

tcollinsworth avatar Nov 03 '23 04:11 tcollinsworth

Yes I'll send a PR within the week

ozyman42 avatar Nov 07 '23 18:11 ozyman42

So I came to an unfortunate conclusion behind why they refresh metric was 0. When I set process.env.AXIOS_DNS_CACHE_TTL_MS then this code doesn't run. So instead of a PR for adding cache eviction events I'll instead be looking for where this bug is For context, I set it to 30 seconds (process.env.AXIOS_DNS_CACHE_TTL_MS = 30 * 1000;)

ozyman42 avatar Nov 08 '23 18:11 ozyman42