Try to retrieve the part from the API in getDetails, if the DTO was not cached before

This commit is contained in:
Jan Böhmer 2024-09-09 00:24:02 +02:00
parent 9a654797ef
commit d4fb2ba46a

View file

@ -420,13 +420,21 @@ class OEMSecretsProvider implements InfoProviderInterface
$cacheItem = $this->partInfoCache->getItem($cacheKey); $cacheItem = $this->partInfoCache->getItem($cacheKey);
if ($cacheItem->isHit()) { if ($cacheItem->isHit()) {
$details = $cacheItem->get(); return $cacheItem->get();
} else { }
// If the details are not found in the cache, throw an exception //If we have no cached result yet, we extract the part number (first part of our ID) and search for it
throw new \RuntimeException("Details not found for provider_id $id"); $partNumber = explode('|', $id)[0];
//The searchByKeyword method will write the results to cache, so we can just try it again afterwards
$this->searchByKeyword($partNumber);
$cacheItem = $this->partInfoCache->getItem($cacheKey);
if ($cacheItem->isHit()) {
return $cacheItem->get();
} }
return $details; // If the details still are not found in the cache, throw an exception
throw new \RuntimeException("Details not found for provider_id $id");
} }