io-developer / php-whois

PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 8.0 compatible (5.4+ old versions)
MIT License
437 stars 117 forks source link

A way to "cache" Whois response in the Whois client class #197

Closed arall closed 1 year ago

arall commented 1 year ago

Description
I'm working in a script to perform large amount of Whois requests, where speed is a key factor.

The "problem" that I'm facing is that, if I want to store the raw response, together with the parsed response, the Whois "client" is performing two resolutions requests for the same domain.

Would be handy in such cases to store the raw-text somehow, and avoid calling a second time.

Example


use Iodev\Whois\Factory;

$time_start = microtime(true);

$domain = 'arall.net';
$client = Factory::get()->createWhois();

$client->loadDomainInfo($domain);
$this->info('Time: ' . microtime(true) - $time_start);
# Time: 0.48427700996399

$client->lookupDomain($domain);
$this->info('Time: ' . microtime(true) - $time_start);
# Time: 0.92632818222046
io-developer commented 1 year ago

Hi, Check Loaders package - https://github.com/io-developer/php-whois/tree/master/src/Iodev/Whois/Loaders There is interface ILoader for a custom loader implementation. And caching example - https://github.com/io-developer/php-whois/blob/master/src/Iodev/Whois/Loaders/MemcachedLoader.php

io-developer commented 1 year ago

https://github.com/io-developer/php-whois#response-caching