* dns.el (query-dns-cached): New function.
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 16 May 2005 19:45:42 +0000 (19:45 +0000)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 16 May 2005 19:45:42 +0000 (19:45 +0000)
lisp/ChangeLog
lisp/dns.el

index efaa77c..a4cc6c0 100644 (file)
@@ -1,3 +1,7 @@
+2005-05-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * dns.el (query-dns-cached): New function.
+
 2005-05-16  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * dgnushack.el: Autoload mail-extract-address-components for XEmacs.
index b2001b1..4de3f3c 100644 (file)
@@ -348,6 +348,18 @@ If TCP-P, the first two bytes of the package with be the length field."
         ;; connection to the DNS server.
         (open-network-stream "dns" (current-buffer) server "domain")))))
 
+(defvar dns-cache (make-vector 4096 0))
+
+(defun query-dns-cached (name &optional type fullp reversep)
+  (let* ((key (format "%s:%s:%s:%s" name type fullp reversep))
+        (sym (intern-soft key dns-cache)))
+    (if (and sym
+            (boundp sym))
+       (symbol-value sym)
+      (let ((result (query-dns name type fullp reversep)))
+       (set (intern key dns-cache) result)
+       result))))
+
 (defun query-dns (name &optional type fullp reversep)
   "Query a DNS server for NAME of TYPE.
 If FULLP, return the entire record returned.