--- whois.module.orig 2010-01-29 10:07:48.000000000 +0000 +++ whois.module 2010-01-29 10:37:00.000000000 +0000 @@ -203,17 +203,31 @@ } elseif ($address != '') { $address = _whois_cleanup_address($address); - include_once($mod_path . '/phpwhois/whois.main.php'); - include_once($mod_path . '/phpwhois/whois.utils.php'); - $whois = new Whois(); - if (variable_get('whois_log_watchdog', 1)) { - // Watchdog entry for lookup request. - watchdog('whois', - 'Whois lookup for: %address', - array('%address' => $address), - WATCHDOG_NOTICE, l('View', "whois/$address") . ' · ' . l('Address', "http://$address/")); + + // check cache first + $cid = 'whois-' . $address; + if (variable_get('whois_cache_enable', 1) && cache_get($cid, "cache") && !empty($cache->data)) { + $whois_results = $cache->data; + } + else { + include_once($mod_path . '/phpwhois/whois.main.php'); + include_once($mod_path . '/phpwhois/whois.utils.php'); + $whois = new Whois(); + if (variable_get('whois_log_watchdog', 1)) { + // Watchdog entry for lookup request. + watchdog('whois', + 'Whois lookup for: %address', + array('%address' => $address), + WATCHDOG_NOTICE, l('View', "whois/$address") . ' · ' . l('Address', "http://$address/")); + } + $whois_results = $whois->Lookup($address); + + if (variable_get('whois_cache_enable', 1)) { + // cache results + cache_set($cid, $whois_results, "cache", variable_get("whois_cache_time", 86400)); + } } - return $whois->Lookup($address); + return $whois_results; } return FALSE; }