mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-16 14:39:37 +00:00
Use xxh3 hashes instead of encoding for info provider cache keys
This commit is contained in:
parent
c17cf2baa1
commit
6afca44897
1 changed files with 3 additions and 3 deletions
|
|
@ -82,7 +82,7 @@ final class PartInfoRetriever
|
||||||
protected function searchInProvider(InfoProviderInterface $provider, string $keyword): array
|
protected function searchInProvider(InfoProviderInterface $provider, string $keyword): array
|
||||||
{
|
{
|
||||||
//Generate key and escape reserved characters from the provider id
|
//Generate key and escape reserved characters from the provider id
|
||||||
$escaped_keyword = urlencode($keyword);
|
$escaped_keyword = hash('xxh3', $keyword);
|
||||||
return $this->partInfoCache->get("search_{$provider->getProviderKey()}_{$escaped_keyword}", function (ItemInterface $item) use ($provider, $keyword) {
|
return $this->partInfoCache->get("search_{$provider->getProviderKey()}_{$escaped_keyword}", function (ItemInterface $item) use ($provider, $keyword) {
|
||||||
//Set the expiration time
|
//Set the expiration time
|
||||||
$item->expiresAfter(!$this->debugMode ? self::CACHE_RESULT_EXPIRATION : 1);
|
$item->expiresAfter(!$this->debugMode ? self::CACHE_RESULT_EXPIRATION : 1);
|
||||||
|
|
@ -108,7 +108,7 @@ final class PartInfoRetriever
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate key and escape reserved characters from the provider id
|
//Generate key and escape reserved characters from the provider id
|
||||||
$escaped_part_id = urlencode($part_id);
|
$escaped_part_id = hash('xxh3', $part_id);
|
||||||
return $this->partInfoCache->get("details_{$provider_key}_{$escaped_part_id}", function (ItemInterface $item) use ($provider, $part_id) {
|
return $this->partInfoCache->get("details_{$provider_key}_{$escaped_part_id}", function (ItemInterface $item) use ($provider, $part_id) {
|
||||||
//Set the expiration time
|
//Set the expiration time
|
||||||
$item->expiresAfter(!$this->debugMode ? self::CACHE_DETAIL_EXPIRATION : 1);
|
$item->expiresAfter(!$this->debugMode ? self::CACHE_DETAIL_EXPIRATION : 1);
|
||||||
|
|
@ -145,4 +145,4 @@ final class PartInfoRetriever
|
||||||
|
|
||||||
return $this->dto_to_entity_converter->convertPart($details);
|
return $this->dto_to_entity_converter->convertPart($details);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue