Remove static cache from our_address in favour of Cache::class keyed off setup:system_id
This commit is contained in:
parent
9abfd88e3d
commit
92f964f572
@ -2,6 +2,7 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
use App\Models\{Address,Domain,Setup};
|
||||
|
||||
@ -92,16 +93,15 @@ if (! function_exists('hexstr')) {
|
||||
*/
|
||||
function our_address(Domain|Address $o=NULL): Collection|Address|NULL
|
||||
{
|
||||
static $so = NULL;
|
||||
static $our = NULL;
|
||||
$so = Cache::remember('so',5,function() {
|
||||
return Setup::findOrFail(config('app.id'));
|
||||
});
|
||||
|
||||
if (! $so)
|
||||
$so = Setup::findOrFail(config('app.id'));
|
||||
|
||||
if (! $our) {
|
||||
$our = Cache::remember(sprintf('%d-akas',$so->system_id),60,function() use ($so) {
|
||||
$so->load(['system.akas.zone.domain']);
|
||||
$our = $so->system->akas;
|
||||
}
|
||||
|
||||
return $so->system->akas;
|
||||
});
|
||||
|
||||
// If we dont have any addresses
|
||||
if ($our->count() === 0)
|
||||
|
@ -4,6 +4,7 @@ namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\{Address,Domain,Setup,System};
|
||||
@ -268,10 +269,12 @@ class RoutingTest extends TestCase
|
||||
|
||||
public function test_complex_rc_nc_hc_us()
|
||||
{
|
||||
Cache::forget('so');
|
||||
$setup = Setup::findOrFail(config('app.id'));
|
||||
$ao = Address::findFTN('100:10/0.0@a');
|
||||
$setup->system_id = $ao->system_id;
|
||||
$setup->save();
|
||||
$this->assertEquals('100:10/0.0@a',our_address($ao)?->ftn);
|
||||
|
||||
$this->session_rc();
|
||||
//$this->session_nc();
|
||||
@ -303,6 +306,7 @@ class RoutingTest extends TestCase
|
||||
|
||||
$ao = Address::findFTN('100:10/22.0@a');
|
||||
$this->assertEquals('100:10/20.0@a',$ao->parent()->ftn);
|
||||
Cache::forget('so');
|
||||
}
|
||||
|
||||
// A points parent is the node, if we have traffic for a point and we have session details for the node
|
||||
|
Loading…
Reference in New Issue
Block a user