[GH-ISSUE #486] Ensure Resolver functions currectly with cache size 0 #204

Closed
opened 2026-03-07 22:46:39 +03:00 by kerem · 2 comments
Owner

Originally created by @hawkw on GitHub (May 23, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/486

Conduit uses trust-dns-resolver as one component of a service discovery system that incorporates multiple information sources, and we implement our own protocol-independent caching on top of it. Therefore, we would like to be able to disable Trust-DNS' caching (see https://github.com/runconduit/conduit/issues/711#issuecomment-385759306 for more information). I suspect there are other use-cases where users might want to disable the resolver's caching.

I've done some testing of the lru-cache crate that's used to implement resolver's DnsLru cache, and it appears that setting the cache's size to 0 disables caching without causing any unexpected behaviour there.

Test indicating that `lru-cache` works with cache size 0
    #[test]
    fn test_zero_capacity() {
        let mut cache = LruCache::new(0);
        cache.insert(1, 10);
        cache.insert(2, 20);
        assert_eq!(cache.capacity(), 0);
        assert!(cache.get_mut(&1).is_none());
        assert!(cache.get_mut(&2).is_none());
    }

However, we should also ensure that disabling the cache doesn't break any of trust-dns-resolver's functionality. In particular, @briansmith suggested in https://github.com/runconduit/conduit/pull/974#issuecomment-391171017 that we should add a test ensuring that CNAME chain resolution works correctly with the cache disabled.

Originally created by @hawkw on GitHub (May 23, 2018). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/486 Conduit uses `trust-dns-resolver` as one component of a service discovery system that incorporates multiple information sources, and we implement our own protocol-independent caching on top of it. Therefore, we would like to be able to disable Trust-DNS' caching (see https://github.com/runconduit/conduit/issues/711#issuecomment-385759306 for more information). I suspect there are other use-cases where users might want to disable the resolver's caching. I've done some testing of the `lru-cache` crate that's used to implement `resolver`'s `DnsLru` cache, and it appears that setting the cache's size to 0 disables caching without causing any unexpected behaviour there. <details> <summary> Test indicating that `lru-cache` works with cache size 0</summary> ```rust #[test] fn test_zero_capacity() { let mut cache = LruCache::new(0); cache.insert(1, 10); cache.insert(2, 20); assert_eq!(cache.capacity(), 0); assert!(cache.get_mut(&1).is_none()); assert!(cache.get_mut(&2).is_none()); } ``` </details> However, we should also ensure that disabling the cache doesn't break any of `trust-dns-resolver`'s functionality. In particular, @briansmith suggested in https://github.com/runconduit/conduit/pull/974#issuecomment-391171017 that we should add a test ensuring that CNAME chain resolution works correctly with the cache disabled.
kerem closed this issue 2026-03-07 22:46:44 +03:00
Author
Owner

@hawkw commented on GitHub (May 23, 2018):

I intend to start on this shortly, but figured it was worth opening an issue to track regardless.

<!-- gh-comment-id:391434911 --> @hawkw commented on GitHub (May 23, 2018): I intend to start on this shortly, but figured it was worth opening an issue to track regardless.
Author
Owner

@hawkw commented on GitHub (May 23, 2018):

Ah, so I just looked at the tests in integration-tests/tests/lookup_tests.rs, and it looks like all the tests already use a CachingClient with cache size 0, including the tests for CNAME chain lookup:

github.com/bluejekyll/trust-dns@0105b8188a/integration-tests/tests/lookup_tests.rs (L242-L274)

So it appears this is already resolved! I guess I should have looked closer at the integration tests prior to opening this issue 😓.

/cc @briansmith

<!-- gh-comment-id:391439864 --> @hawkw commented on GitHub (May 23, 2018): Ah, so I just looked at the tests in `integration-tests/tests/lookup_tests.rs`, and it looks like all the tests already use a `CachingClient` with cache size 0, including the tests for CNAME chain lookup: https://github.com/bluejekyll/trust-dns/blob/0105b8188a6a2f1f9f03b05772c1eb7c09e68965/integration-tests/tests/lookup_tests.rs#L242-L274 So it appears this is already resolved! I guess I should have looked closer at the integration tests prior to opening this issue 😓. /cc @briansmith
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#204
No description provided.