Esempio n. 1
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="answers">Dns answers.</param>
 /// <param name="addTime">Entry add time.</param>
 public DnsCacheEntry(DnsServerResponse answers,DateTime addTime)
 {
     m_pResponse = answers;
     m_Time      = addTime;
 }
Esempio n. 2
0
        /// <summary>
        /// Adds dns records to cache. If old entry exists, it is replaced.
        /// </summary>
        /// <param name="qname"></param>
        /// <param name="qtype"></param>
        /// <param name="answers"></param>
        public static void AddToCache(string qname,int qtype,DnsServerResponse answers)
        {
            if(answers == null){
                return;
            }

            try{
                lock(m_pCache){
                    // Remove old cache entry, if any.
                    if(m_pCache.Contains(qname + qtype)){
                        m_pCache.Remove(qname + qtype);
                    }
                    m_pCache.Add(qname + qtype,new DnsCacheEntry(answers,DateTime.Now));
                }
            }
            catch{
            }
        }