class Roma::DNSCache

Public Class Methods

new() click to toggle source
   # File lib/roma/dns_cache.rb
 7 def initialize
 8   @@addrs = {}
 9   @@enabled_caching = false
10   if Config.const_defined?(:DNS_CACHING)
11     @@enabled_caching = Config::DNS_CACHING
12   end
13 end

Public Instance Methods

disable_dns_cache() click to toggle source
   # File lib/roma/dns_cache.rb
25 def disable_dns_cache
26   @@enabled_caching = false
27   @@addrs.clear
28 end
enable_dns_cache() click to toggle source
   # File lib/roma/dns_cache.rb
30 def enable_dns_cache
31   @@enabled_caching = true
32 end
get_stat() click to toggle source
   # File lib/roma/dns_cache.rb
34 def get_stat
35   ret = {}
36   ret["dns_caching"] = @@enabled_caching
37   ret
38 end
resolve_name(host) click to toggle source
   # File lib/roma/dns_cache.rb
15 def resolve_name(host)
16   return host unless @@enabled_caching
17 
18   unless @@addrs.include?(host)
19     res = TCPSocket.gethostbyname(host)
20     @@addrs[host] = res[3]
21   end
22   @@addrs[host]
23 end