ClassesBigCommerceProxyProxy Cache

Proxy_Cache

Proxy_Cache class

  • Full name: \BigCommerce\Proxy\Proxy_Cache

Constants

ConstantVisibilityTypeValue
CACHE_GROUP_NAMESPACEpublic’bigcommerce_proxy’
PRODUCTS_PATHpublic’/catalog/products’
CATEGORIES_PATHpublic’/catalog/categories’
BRANDS_PATHpublic’/catalog/brands’
VARIANTS_PATHpublic’/catalog/variants’
SUMMARY_PATHpublic’/catalog/summary’
CHANNELS_PATHpublic’/channels’
CACHE_TTLpublic10 * MINUTE_IN_SECONDS
GENERATION_KEY_LENGTHpublic5

Methods

__construct

Proxy_Cache constructor.

public __construct(array $config): mixed

Parameters:

ParameterTypeDescription
$configarrayConfiguration details.

get_request_route_path

Returns all parts of a REST route after the base.

public get_request_route_path(\WP_REST_Request $request): string

Parameters:

ParameterTypeDescription
$request\WP_REST_RequestRequest object.

Return Value:

The request path.


get_generation

Provides a generation key for a cache group.

public get_generation(string $cache_group): string

Parameters:

ParameterTypeDescription
$cache_groupstringCache group name.

Return Value:

Cache generation key.


get_cache_key

Build a cache key from request args.

public get_cache_key(\WP_REST_Request $request, string $cache_group): string

Parameters:

ParameterTypeDescription
$request\WP_REST_RequestRequest instance.
$cache_groupstringCache group name.

Return Value:

Cache key.


get_cache_group_name

Returns a cache group name for a given REST request.

public get_cache_group_name(string $route = null): string

Parameters:

ParameterTypeDescription
$routestringREST request route.

Return Value:

Cache group name or an empty string if no cache group applies.


handle_result

Caches responses from the BigCommerce API.

public handle_result(mixed $result, \WP_REST_Request $request): void

Parameters:

ParameterTypeDescription
$resultmixedResults returned by the BigCommerce API.
$request\WP_REST_RequestREST request.

cache_result

Caches data.

public cache_result(mixed $data, string $cache_key, string $cache_group): mixed

Parameters:

ParameterTypeDescription
$datamixedData to cache.
$cache_keystringCache key.
$cache_groupstringCache group name.

get_result

Fetch results from cache if $results are empty.

public get_result(mixed $result, \WP_REST_Request $request): bool|mixed

Parameters:

ParameterTypeDescription
$resultmixedProxy results (This should be empty unless results are provided by extension).
$request\WP_REST_RequestRequest instance.

Return Value:

Result.


get_data_from_cache

Gets cached data.

public get_data_from_cache(string $cache_key, string $cache_group): mixed

Parameters:

ParameterTypeDescription
$cache_keystringA hash built from the request URL.
$cache_groupstringThe request’s cache group.

Return Value:

Data or false if unsuccessful.


bust_cache_group

Deletes a transient cache group

public bust_cache_group(string $cache_group): mixed

Parameters:

ParameterTypeDescription
$cache_groupstringCache group name.

bust_product_cache

Busts cache data related to a product that has been updated.

public bust_product_cache(int $product_id): mixed

Parameters:

ParameterTypeDescription
$product_idintThe BigCommerce product ID.


Automatically generated on 2025-01-21