Interface DnsCache


@UnstableApi public interface DnsCache
A cache for DNS responses.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a listener to this DnsCache.
    Returns a new DnsCacheBuilder.
    default void
    cache(io.netty.handler.codec.dns.DnsQuestion question, io.netty.handler.codec.dns.DnsRecord... records)
    Caches a successful resolution.
    void
    cache(io.netty.handler.codec.dns.DnsQuestion question, Iterable<? extends io.netty.handler.codec.dns.DnsRecord> records)
    Caches a successful resolution.
    void
    cache(io.netty.handler.codec.dns.DnsQuestion question, UnknownHostException cause)
    Caches a failed resolution.
    @Nullable List<io.netty.handler.codec.dns.DnsRecord>
    get(io.netty.handler.codec.dns.DnsQuestion question)
    Returns the DnsRecords associated with the DnsQuestion in this cache.
    static DnsCache
    of(String cacheSpec)
    Returns a newly-created DnsCache using the specified cacheSpec.
    static DnsCache
    Returns the default DNS cache.
    void
    remove(io.netty.handler.codec.dns.DnsQuestion question)
    Discards any cached value for the hostname.
    void
    Discards all entries in this cache.
  • Method Details

    • ofDefault

      static DnsCache ofDefault()
      Returns the default DNS cache.
    • of

      static DnsCache of(String cacheSpec)
      Returns a newly-created DnsCache using the specified cacheSpec.
    • builder

      static DnsCacheBuilder builder()
      Returns a new DnsCacheBuilder.
    • cache

      default void cache(io.netty.handler.codec.dns.DnsQuestion question, io.netty.handler.codec.dns.DnsRecord... records)
      Caches a successful resolution.
      Parameters:
      question - the DNS question.
      records - the DNS records associated to the given DnsQuestion.
    • cache

      void cache(io.netty.handler.codec.dns.DnsQuestion question, Iterable<? extends io.netty.handler.codec.dns.DnsRecord> records)
      Caches a successful resolution.
      Parameters:
      question - the DNS question.
      records - the DNS records associated to the given DnsQuestion.
    • cache

      void cache(io.netty.handler.codec.dns.DnsQuestion question, UnknownHostException cause)
      Caches a failed resolution.
      Parameters:
      question - the DNS question.
      cause - the resolution failure.
    • get

      @Nullable @Nullable List<io.netty.handler.codec.dns.DnsRecord> get(io.netty.handler.codec.dns.DnsQuestion question) throws UnknownHostException
      Returns the DnsRecords associated with the DnsQuestion in this cache. null if this cache contains no resolution for the DnsQuestion.
      Throws:
      UnknownHostException - if the DnsQuestion previously failed with the UnknownHostException and its negative TTL is valid.
    • remove

      void remove(io.netty.handler.codec.dns.DnsQuestion question)
      Discards any cached value for the hostname.
    • removeAll

      void removeAll()
      Discards all entries in this cache.
    • addListener

      void addListener(DnsCacheListener listener)
      Adds a listener to this DnsCache. The DnsCacheListener is notified whenever an event occurs.