mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-20 17:19:34 +00:00
Try to retrieve the part from the API in getDetails, if the DTO was not cached before
This commit is contained in:
parent
9a654797ef
commit
d4fb2ba46a
1 changed files with 14 additions and 6 deletions
|
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue