肥皂电话需要很多时间
Soap call takes a lot of time
我正在开发专用于 prestashop 模块的网络服务,这需要花费大量时间。
Web 服务 return 每次调用的运费,所以如果我有 4 个运输工具,prestashop 会调用 8 个调用(4 个用于集团购物车,4 个用于在订单页面上获取运费)。
有什么解决办法可以减少这个时间吗?就像使用静态变量一样。
我尝试了缓存但没有效果,因为 wsdl 已经在我的服务器上了。
您必须缓存网络服务结果以提高性能:
if (Cache::isStored('unique-id-for-your-module-and-request-result-' . Tools::jsonEncode($request_params)))
{
$shipment_options = Cache::retrieve('unique-id-for-your-module-and-request-result-' . Tools::jsonEncode($request_params));
}
else
{
$shipment_options = $api_or_soap->getEstimateCost($request_params);
if ($shipment_options)
Cache::store('unique-id-for-your-module-and-request-result-' . Tools::jsonEncode($request_params), $shipment_options);
}
祝你好运
我正在开发专用于 prestashop 模块的网络服务,这需要花费大量时间。 Web 服务 return 每次调用的运费,所以如果我有 4 个运输工具,prestashop 会调用 8 个调用(4 个用于集团购物车,4 个用于在订单页面上获取运费)。 有什么解决办法可以减少这个时间吗?就像使用静态变量一样。 我尝试了缓存但没有效果,因为 wsdl 已经在我的服务器上了。
您必须缓存网络服务结果以提高性能:
if (Cache::isStored('unique-id-for-your-module-and-request-result-' . Tools::jsonEncode($request_params)))
{
$shipment_options = Cache::retrieve('unique-id-for-your-module-and-request-result-' . Tools::jsonEncode($request_params));
}
else
{
$shipment_options = $api_or_soap->getEstimateCost($request_params);
if ($shipment_options)
Cache::store('unique-id-for-your-module-and-request-result-' . Tools::jsonEncode($request_params), $shipment_options);
}
祝你好运