Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entry source, either cache or query #63

Merged
merged 1 commit into from
Aug 5, 2022

Conversation

monkbroc
Copy link
Contributor

@monkbroc monkbroc commented Aug 5, 2022

When adding instrumentation around DNS lookups, it would be very helpful to be able to distinguish if an entry came from the cache or a fresh query. This would allow to compute the cache hit rate and to calculate stats on the duration of DNS queries, ignoring when the cache is hit.

The source is either cache or query. It is returned with the entry from lookupAsync and it is added as an extra parameter to the callback from lookup.

I didn't add the source parameter to the callback type definitions in https://github.com/szmarczak/cacheable-lookup/blob/master/index.d.ts#L102-L105 since the expires and ttl were already omitted. I wasn't sure if that was on purpose or if it was an omission.

@szmarczak szmarczak merged commit 185a8a4 into szmarczak:master Aug 5, 2022
@szmarczak
Copy link
Owner

Thanks a lot! ❤️

@szmarczak
Copy link
Owner

Released cacheable-lookup@6.1.0 🎉

@szmarczak
Copy link
Owner

I wasn't sure if that was on purpose or if it was an omission.

It was on purpose to make the typings compatible.

@monkbroc monkbroc deleted the lookup-source branch August 12, 2022 21:31
@monkbroc
Copy link
Contributor Author

Thanks for merging and releasing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants