Skip to content

Commit

Permalink
Add invalidate and reload
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant committed Nov 27, 2024
1 parent 31db60b commit 0fdc1a2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
9 changes: 9 additions & 0 deletions app/Facades/LibrenmsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Log;

class LibrenmsConfig extends Facade
{
Expand All @@ -40,4 +41,12 @@ public static function reload(): void
App::forgetInstance('librenms-config'); // clear singleton
self::clearResolvedInstances(); // clear facade resolved instances cache
}

public static function invalidateAndReload(): void
{
self::invalidateCache();
self::reload();

Log::info('LibreNMS config cache cleared and config reloaded.');
}
}
3 changes: 1 addition & 2 deletions discovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
echo "DEBUG!\n";
Debug::setVerbose(isset($options['v']));
\LibreNMS\Util\OS::updateCache(true); // Force update of OS Cache
LibrenmsConfig::invalidateCache();
LibrenmsConfig::reload();
LibrenmsConfig::invalidateAndReload();
}

if (! $where) {
Expand Down
3 changes: 1 addition & 2 deletions scripts/collect-snmp-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@

echo 'Capturing Data: ';
\LibreNMS\Util\OS::updateCache(true); // Force update of OS Cache
LibrenmsConfig::invalidateCache();
LibrenmsConfig::reload();
LibrenmsConfig::invalidateAndReload();
$capture->captureFromDevice($device['device_id'], $prefer_new_snmprec, $full);
echo "\nVerify these file(s) do not contain any private data before sharing!\n";
} catch (InvalidModuleException $e) {
Expand Down
3 changes: 1 addition & 2 deletions scripts/save-test-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@
echo PHP_EOL;

\LibreNMS\Util\OS::updateCache(true); // Force update of OS Cache
LibrenmsConfig::invalidateCache();
LibrenmsConfig::reload();
LibrenmsConfig::invalidateAndReload();
$tester = new ModuleTestHelper($modules, $target_os, $target_variant);
if (! $no_save && ! empty($output_file)) {
$tester->setJsonSavePath($output_file);
Expand Down
3 changes: 1 addition & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
}

\LibreNMS\Util\OS::updateCache(true); // Force update of OS Cache
LibrenmsConfig::invalidateCache();
LibrenmsConfig::reload();
LibrenmsConfig::invalidateAndReload();

app()->terminate(); // destroy the bootstrap Laravel application

0 comments on commit 0fdc1a2

Please sign in to comment.