da81f1ddf1
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
30 lines
613 B
PHP
30 lines
613 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXC\Service;
|
|
|
|
use KTXC\Models\Firewall\FirewallRuleObject;
|
|
use KTXC\Stores\FirewallStore;
|
|
|
|
final class FirewallRuleCache
|
|
{
|
|
/** @var array<string, FirewallRuleObject[]> */
|
|
private array $rules = [];
|
|
|
|
public function __construct(private readonly FirewallStore $store)
|
|
{
|
|
}
|
|
|
|
/** @return FirewallRuleObject[] */
|
|
public function applicable(string $tenantId): array
|
|
{
|
|
return $this->rules[$tenantId] ??= $this->store->listApplicableRules($tenantId);
|
|
}
|
|
|
|
public function invalidate(): void
|
|
{
|
|
$this->rules = [];
|
|
}
|
|
}
|