Browse Source

cache resolved host in memory

PHP-GTK3
yggverse 8 months ago
parent
commit
ae13151936
  1. 53
      src/Box/Main.php

53
src/Box/Main.php

@ -72,29 +72,49 @@ class Main
function ($entry) function ($entry)
{ {
global $config; global $config;
global $memory;
$this->tray->label->set_text(
sprintf(
'Open %s...',
$entry->get_text()
)
);
$start = microtime(true);
$host = null; $host = null;
if ($config->resolver->enabled) if ($config->resolver->enabled)
{ {
$resolve = new \Yggverse\Net\Resolve(
$config->resolver->request->record,
$config->resolver->request->host,
$config->resolver->request->timeout,
$config->resolver->result->shuffle
);
$address = new \Yggverse\Net\Address( $address = new \Yggverse\Net\Address(
$entry->get_text() $entry->get_text()
); );
$resolved = $resolve->address( $name = $address->getHost();
$address
);
if ($resolved) if (!$host = $memory->get($name))
{ {
$host = $resolved->getHost(); // @TODO memory cache $resolve = new \Yggverse\Net\Resolve(
$config->resolver->request->record,
$config->resolver->request->host,
$config->resolver->request->timeout,
$config->resolver->result->shuffle
);
$resolved = $resolve->address(
$address
);
if ($resolved)
{
$host = $resolved->getHost();
$memory->set(
$name,
$host
);
}
} }
} }
@ -103,15 +123,6 @@ class Main
$host $host
); );
$this->tray->label->set_text(
sprintf(
'Open %s...',
$entry->get_text()
)
);
$start = microtime(true);
$raw = $request->getResponse(); $raw = $request->getResponse();
$end = microtime(true); $end = microtime(true);

Loading…
Cancel
Save