Remove static cache from our_address in favour of Cache::class keyed off setup:system_id

This commit is contained in:
2024-04-26 17:27:00 +10:00
parent 9abfd88e3d
commit 92f964f572
2 changed files with 12 additions and 8 deletions

View File

@@ -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)