Attached is a patch to add caching of whois lookups.

Adds a fieldset to the settings page that allows enabling/disabling caching and setting the length to time to cache results.

In whois_get_whois(), we check the cache for the record first, before doing a lookup.

Patched against 6.x-1.3

Comments

Greg Go’s picture

StatusFileSize
new1.64 KB
new1003 bytes

attachments didn't take? attaching again.

helmo’s picture

Status: Needs review » Patch (to be ported)

The code looks promising, and would probably also fix #151861: Enable logging and a Whois block showing previous lookups.

You should be able to update this to apply to the latest cvs with only minor adjustments.

Greg Go’s picture

StatusFileSize
new4.44 KB
new4.91 KB

Added a setting for logging / not logging cached lookups.

Rerolled the patches against DRUPAL-6--1 and HEAD. I'm not sure I did this right... first time submitting. Also, the D7 version is untested since I don't have a D7 install ready to go.

I think I can tackle the other issue too by pulling from the watchdog table but one thing at a time.

helmo’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new5.95 KB

I adapted the patch a little bit.

* Only cache if no error occured
* include phpwhois lib for the Util class
* Include "(cached)" in the watchdog line when serving a cached result
* show the cache date

What do you think?

Greg Go’s picture

It looks good!

The only problem I see was a comment I left in the settings -- "Log available as a block or a table at admin/reports/whois." I took that out since we haven't added that functionality in yet. Re-rolled.

helmo’s picture

Status: Needs review » Fixed

Thanks,

I just committed to DRUPAL-6--1 and HEAD.

Some thoughts for the future... maybe a refresh button or 'don't use cache' checkbox might come in handy for some people.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.