mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
FDB Tables improve performance (#15333)
* FDB Tables improve performance Reduce unnecessary sql queries, by using a relationship Cache vendor oui lookups * Oui already "clean" * Fix typo
This commit is contained in:
@@ -27,6 +27,7 @@ namespace LibreNMS\Util;
|
||||
|
||||
use App\Models\Device;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use LibreNMS\Config;
|
||||
|
||||
@@ -158,10 +159,12 @@ class Rewrite
|
||||
{
|
||||
$oui = substr($mac, 0, 6);
|
||||
|
||||
$results = DB::table('vendor_ouis')
|
||||
->where('oui', 'like', "$oui%") // possible matches
|
||||
->orderBy('oui', 'desc') // so we can check longer ones first if we have them
|
||||
->pluck('vendor', 'oui');
|
||||
$results = Cache::remember($oui, 21600, function () use ($oui) {
|
||||
return DB::table('vendor_ouis')
|
||||
->where('oui', 'like', "$oui%") // possible matches
|
||||
->orderBy('oui', 'desc') // so we can check longer ones first if we have them
|
||||
->pluck('vendor', 'oui');
|
||||
});
|
||||
|
||||
if (count($results) == 1) {
|
||||
return Arr::first($results);
|
||||
|
Reference in New Issue
Block a user