Skip to content

Commit

Permalink
Merge pull request #5834 from derrabus/improvement/cache-keys
Browse files Browse the repository at this point in the history
Document tuple return type of `generateCacheKeys()`
  • Loading branch information
derrabus committed Dec 19, 2022
2 parents b50fbfe + 9c02717 commit 63e513c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Cache/QueryCacheProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function getCacheKey()
* @param array<int, Type|int|string|null>|array<string, Type|int|string|null> $types
* @param array<string, mixed> $connectionParams
*
* @return string[]
* @return array{string, string}
*/
public function generateCacheKeys($sql, $params, $types, array $connectionParams = [])
{
Expand All @@ -127,11 +127,7 @@ public function generateCacheKeys($sql, $params, $types, array $connectionParams
'&connectionParams=' . hash('sha256', serialize($connectionParams));

// should the key be automatically generated using the inputs or is the cache key set?
if ($this->cacheKey === null) {
$cacheKey = sha1($realCacheKey);
} else {
$cacheKey = $this->cacheKey;
}
$cacheKey = $this->cacheKey ?? sha1($realCacheKey);

return [$cacheKey, $realCacheKey];
}
Expand Down

0 comments on commit 63e513c

Please sign in to comment.