ClassesBigCommerceApiCaching Client

Caching_Client

Implements a short-term caching mechanism around API requests to reduce redundant calls, particularly useful for operations like cart handling. The cache is invalidated after any write operation to ensure data consistency.

Methods

callApi

Perform an API call, utilizing caching for read operations.

public callApi(string $resourcePath, string $method, array $queryParams, array $postData, array $headerParams, string|null $responseType = null, string|null $endpointPath = null): array

If the operation is a write, the cache generation key is updated to invalidate previous cache. For read operations, the cache is checked first before making an API request.

Parameters:

ParameterTypeDescription
$resourcePathstringPath to the API endpoint.
$methodstringHTTP method (e.g., GET, POST).
$queryParamsarrayQuery parameters for the request.
$postDataarrayData to include in the POST body.
$headerParamsarrayHeaders to include in the request.
$responseTypestring|nullExpected response type (optional).
$endpointPathstring|nullEndpoint path before parameter expansion (optional).

Return Value:

Response data from the API or cache.

Throws:

If a non-2xx response is received.


Inherited methods

__construct

Constructor for the Base_Client class

public __construct(\BigCommerce\Api\Configuration|null $config = null): mixed

Initializes the API client with the provided configuration. If no configuration is provided, it will use the default configuration.

Parameters:

ParameterTypeDescription
$config\BigCommerce\Api\Configuration|nullThe configuration for this ApiClient.

getConfig

Gets the configuration of the API client

public getConfig(): \BigCommerce\Api\Configuration

Returns the configuration object used by the API client.

Return Value:

Returns the Configuration object used by this API client.



Automatically generated on 2025-01-21