Use xxh3 hashes instead of encoding for info provider cache keys

This commit is contained in:
Jan Böhmer 2026-02-15 22:19:44 +01:00
parent c17cf2baa1
commit 6afca44897

View file

@ -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);
} }
} }