tokio-dns icon indicating copy to clipboard operation
tokio-dns copied to clipboard

Add LRU cache support

Open loggerhead opened this issue 8 years ago • 6 comments

Does this crate have the cache support? I am not carefully review the source code, but seems there have no cache support.

loggerhead avatar Sep 10 '16 01:09 loggerhead

There's no caching inside this crate, but since it uses getaddrinfo, there might be caching involved behind the scenes, depending on the operating system.

sbstp avatar Sep 10 '16 01:09 sbstp

So, any plan to support caching? I think provide a clear, controllable caching to user is better than the potential system caching. Maybe you can consider to use lru_time_cache to provide a optional caching.

loggerhead avatar Sep 13 '16 07:09 loggerhead

  1. How do you want to pick the time the info should stay in the cache? We don't have access to TTL information. Let the user configure it?
  2. The lru_time_cache crate is licensed under the GPL-3.0, so we can't use their library in this crate without changing the license.

sbstp avatar Sep 13 '16 15:09 sbstp

  1. Yes, give user the option to configure it depend on their use case.
  2. How about lru-cache? It support cache with capacity limit.

loggerhead avatar Sep 16 '16 01:09 loggerhead

I think that a cache option could be added to the CpuPoolResolver, but I wouldn't give the default resolver a cache (the lazy static one). So you could only get cache benefits by using a custom resolver, and the *_with methods. Does that sound fair to you? Also do you want to implement it or should I?

sbstp avatar Sep 16 '16 04:09 sbstp

It's ok. I just want use your lib in my next project, and I am a little busy currently. So, it's not hurry. But it would be helpful if you can give more examples about how to use your lib, like: how to implement a simple custom resolver : )

loggerhead avatar Sep 16 '16 06:09 loggerhead