fix(cache): resolve all cached brands before deleting collection key in BrandCache reset (F-2026-0002)
This commit is contained in:
parent
dd5bcdd351
commit
861a1a8146
1 changed files with 8 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ use Domain\Models\ValueObjects\Brand\ArcadiaId;
|
|||
use Domain\Models\ValueObjects\Brand\BrandCode;
|
||||
use Domain\Models\ValueObjects\Brand\BrandId;
|
||||
use Domain\Models\ValueObjects\Brand\BrandName;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ final readonly class BrandCache
|
|||
|
||||
public function __construct(
|
||||
private CacheInterface $cacheStore,
|
||||
private \Psr\Log\LoggerInterface $logger,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -30,6 +31,7 @@ final readonly class BrandCache
|
|||
return $this->fromCacheData($this->cacheStore->get($this->idKey($id)));
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->warning('BrandCache::getById failed', ['exception' => $e->getMessage()]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +42,7 @@ final readonly class BrandCache
|
|||
return $this->fromCacheData($this->cacheStore->get($this->codeKey($code)));
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->warning('BrandCache::getByCode failed', ['exception' => $e->getMessage()]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -50,6 +53,7 @@ final readonly class BrandCache
|
|||
return $this->fromCacheData($this->cacheStore->get($this->arcadiaKey($arcadiaId)));
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->warning('BrandCache::getByArcadiaId failed', ['exception' => $e->getMessage()]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -81,6 +85,7 @@ final readonly class BrandCache
|
|||
return $brands;
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->warning('BrandCache::getAll failed', ['exception' => $e->getMessage()]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -127,9 +132,10 @@ final readonly class BrandCache
|
|||
public function reset(): void
|
||||
{
|
||||
try {
|
||||
$all = $this->getAll();
|
||||
|
||||
$this->cacheStore->delete(self::KEY_ALL);
|
||||
|
||||
$all = $this->getAll();
|
||||
if ($all !== null) {
|
||||
foreach ($all as $brand) {
|
||||
$this->cacheStore->delete($this->idKey($brand->id()));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue