proxy = $proxy; $this->cache = $cache; } /** * Implements caching for the proxy interface. * * @param array $query The query arguments to send to the remote API. * @return array|false The response from the remote API, or false if the * response is empty. */ public function get_items( array $query ) { $cache_key = 'parsely_api_' . wp_hash( (string) wp_json_encode( $this->proxy ) ) . '_' . wp_hash( (string) wp_json_encode( $query ) ); $items = $this->cache->get( $cache_key, self::CACHE_GROUP ); if ( false === $items ) { $items = $this->proxy->get_items( $query ); $this->cache->set( $cache_key, $items, self::CACHE_GROUP, self::OBJECT_CACHE_TTL ); } return $items; } }