remote_api = $remote_api; $this->cache = $cache; } /** * Implements caching for the Remote API interface. * * @param array $query The query arguments to send to the remote API. * @param bool $associative Always `false`, just present to make definition compatible with interface. * * @return array|WP_Error|false The response from the remote API, or false if the * response is empty. */ public function get_items( $query, $associative = false ) { $cache_key = 'parsely_api_' . wp_hash( $this->remote_api->get_endpoint() ) . '_' . wp_hash( (string) wp_json_encode( $query ) ); /** * Variable. * * @var array|false */ $items = $this->cache->get( $cache_key, self::CACHE_GROUP ); if ( false === $items ) { $items = $this->remote_api->get_items( $query ); $this->cache->set( $cache_key, $items, self::CACHE_GROUP, self::OBJECT_CACHE_TTL ); } return $items; } /** * Checks if the current user is allowed to make the API call. * * @since 3.7.0 * * @return bool */ public function is_user_allowed_to_make_api_call(): bool { return $this->remote_api->is_user_allowed_to_make_api_call(); } }