[GH-ISSUE #3356] Invalidate individual cache entries in hickory-resolver #1172

Closed
opened 2026-03-16 01:48:28 +03:00 by kerem · 1 comment
Owner

Originally created by @conradludgate on GitHub (Nov 20, 2025).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/3356

Is your feature request related to a problem? Please describe.

In hickory-resolver, it seems there's currently no way to invalidate the cache of a specific entry.

Describe the solution you'd like

On both Resolver and DnsLru, I would like to have an option to invalidate entries for a given query.

Happy to contribute a PR if desired.

Describe alternatives you've considered

A working alternative for now is to set the cache size to 0 and implement our own caching on top of Resolver

Additional context

We are planning to use DNS to implement service discovery. When we want to connect to the service leader, we need to scan over the entire service IP list to detect the leader.

The reason we want to invalidate the cache is that this IP list might not contain the primary under certain circumstances, and thus we would want to try the discovery process again, fetching an up to date list of IPs from the upstream nameserver.

The reason we want to invalidate individual cache entries is that we have thousands of such services that perform their own individual leader elections. We wouldn't want to use clear_cache() as that would be an unnecessary performance hit for the services that are stable.

Originally created by @conradludgate on GitHub (Nov 20, 2025). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/3356 **Is your feature request related to a problem? Please describe.** In `hickory-resolver`, it seems there's currently no way to invalidate the cache of a specific entry. **Describe the solution you'd like** On both `Resolver` and `DnsLru`, I would like to have an option to invalidate entries for a given query. Happy to contribute a PR if desired. **Describe alternatives you've considered** A working alternative for now is to set the cache size to 0 and implement our own caching on top of `Resolver` **Additional context** We are planning to use DNS to implement service discovery. When we want to connect to the service leader, we need to scan over the entire service IP list to detect the leader. The reason we want to invalidate the cache is that this IP list might not contain the primary under certain circumstances, and thus we would want to try the discovery process again, fetching an up to date list of IPs from the upstream nameserver. The reason we want to invalidate individual cache entries is that we have thousands of such services that perform their own individual leader elections. We wouldn't want to use `clear_cache()` as that would be an unnecessary performance hit for the services that are stable.
kerem closed this issue 2026-03-16 01:48:33 +03:00
Author
Owner

@djc commented on GitHub (Nov 20, 2025):

Happy to contribute a PR if desired.

This seems pretty niche, but if it's reasonably self-contained I'm happy to review.

<!-- gh-comment-id:3559264106 --> @djc commented on GitHub (Nov 20, 2025): > Happy to contribute a PR if desired. This seems pretty niche, but if it's reasonably self-contained I'm happy to review.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#1172
No description provided.