diff --git a/composer.json b/composer.json index 9810e45..4d05c7d 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "trexima/harvey-client", "description": "Client for Harvey API v2", - "version": "1.3.1", + "version": "1.3.2", "type": "library", "license": "MIT", "authors": [ diff --git a/src/Client.php b/src/Client.php index 1763411..94990c9 100644 --- a/src/Client.php +++ b/src/Client.php @@ -179,12 +179,17 @@ public function searchIsco(?string $title = null, ?int $workArea = null, ?string if ($perPage === 0) { $args['pagination'] = false; } - $cacheKey = 'search-isco-' . crc32(json_encode($args)); - $result = $this->cache->get($cacheKey, function (ItemInterface $item) use ($args) { - $item->expiresAfter($this->cacheTtl); + if ($json = json_encode($args)) { + $cacheKey = 'search-isco-' . crc32($json); + $result = $this->cache->get($cacheKey, function (ItemInterface $item) use ($args) { + $item->expiresAfter($this->cacheTtl); + $resource = $this->get('api/isco', $args); + return (string)$resource->getBody(); + }); + } else { $resource = $this->get('api/isco', $args); - return (string)$resource->getBody(); - }); + $result = (string)$resource->getBody(); + } return $this->jsonDecode($result); }