Skip to content

Commit

Permalink
md5 the cache key so it doens’t get bigger than 100
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanbes committed May 23, 2017
1 parent 3142bff commit c29440e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/LoLApi/Api/BaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ protected function callApiUrl($url, array $queryParameters = [])
$queryParameters = array_merge(['api_key' => $this->apiClient->getApiKey()], $queryParameters);
$fullUrl = $this->buildUri($url, $queryParameters);

if ($this->apiClient->getCacheProvider()->contains($fullUrl)) {
return $this->buildApiResult($fullUrl, json_decode($this->apiClient->getCacheProvider()->fetch($fullUrl), true), true);
if ($this->apiClient->getCacheProvider()->contains(md5($fullUrl))) {
return $this->buildApiResult($fullUrl, json_decode($this->apiClient->getCacheProvider()->fetch(md5($fullUrl)), true), true);
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/LoLApi/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,6 @@ public function getBaseUrl()
*/
public function cacheApiResult(ApiResult $apiResult, $ttl = 60)
{
$this->cacheProvider->save($apiResult->getUrl(), json_encode($apiResult->getResult()), $ttl);
$this->cacheProvider->save(md5($apiResult->getUrl()), json_encode($apiResult->getResult()), $ttl);
}
}

0 comments on commit c29440e

Please sign in to comment.