Example #1
0
        /// <summary>
        /// Tries to get dns records from cache, if any.
        /// </summary>
        /// <param name="qname"></param>
        /// <param name="qtype"></param>
        /// <returns>Returns null if not in cache.</returns>
        public static DnsServerResponse GetFromCache(string qname, int qtype)
        {
            try{
                if (m_pCache.Contains(qname + qtype))
                {
                    DnsCacheEntry entry = (DnsCacheEntry)m_pCache[qname + qtype];

                    // If cache object isn't expired
                    if (entry.Time.AddSeconds(m_CacheTime) > DateTime.Now)
                    {
                        return(entry.Answers);
                    }
                }
            }
            catch {
            }

            return(null);
        }