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,16 +420,24 @@ class OEMSecretsProvider implements InfoProviderInterface
|
|||
$cacheItem = $this->partInfoCache->getItem($cacheKey);
|
||||
|
||||
if ($cacheItem->isHit()) {
|
||||
$details = $cacheItem->get();
|
||||
} else {
|
||||
// If the details are not found in the cache, throw an exception
|
||||
throw new \RuntimeException("Details not found for provider_id $id");
|
||||
return $cacheItem->get();
|
||||
}
|
||||
//If we have no cached result yet, we extract the part number (first part of our ID) and search for it
|
||||
$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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A list of capabilities this provider supports (which kind of data it can provide).
|
||||
* Not every part have to contain all of these data, but the provider should be able to provide them in general.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue