Browse Source

cache resolved host in memory

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

39
src/Box/Main.php

@ -72,10 +72,28 @@ 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)
{
$address = new \Yggverse\Net\Address(
$entry->get_text()
);
$name = $address->getHost();
if (!$host = $memory->get($name))
{ {
$resolve = new \Yggverse\Net\Resolve( $resolve = new \Yggverse\Net\Resolve(
$config->resolver->request->record, $config->resolver->request->record,
@ -84,17 +102,19 @@ class Main
$config->resolver->result->shuffle $config->resolver->result->shuffle
); );
$address = new \Yggverse\Net\Address(
$entry->get_text()
);
$resolved = $resolve->address( $resolved = $resolve->address(
$address $address
); );
if ($resolved) if ($resolved)
{ {
$host = $resolved->getHost(); // @TODO memory cache $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