简体   繁体   English

SOAP请求花费太长时间来处理大数据

[英]SOAP request taking too long to process large data

I get an array from other website with helping SOAP client, it's quite big array, you can check it out short version here 我从其他网站获得了一个帮助SOAP客户端的数组,它是一个非常大的数组,你可以在这里查看简短版本
An array 数组

I need to get category names, my code is here, it works but slows website down. 我需要获取类别名称,我的代码在这里,它可以工作,但减慢网站速度。 if anyone can provide better code. 如果有人能提供更好的代码。

$client = new nusoap_client('http://87.253.63.146/b2b/b2bWS?WSDL', 'wsdl');
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$parametrebi = array('user' => '','brand' => '', 'vat_zone' => 'GEVAT', 'currency' => 'GEL', 'all_items' => 'Y', 'page_num' => '1', 'lines_per_page' => '25');

$result = $client->call('GetPriceList', $parametrebi, array('return' => 'xsd:string'), "");
foreach($result['PriceList']['categories']['category'] as $category)
{
    echo '<option value="'.$category['!id'].'">'.$category['!name'].'</option>';
}

Do the categories change that often? 这些类别经常改变吗?
Cant you poll for the categories every so often? 你不能经常轮询这些类别吗?

Eg every 5 min or so make this soap call and either save the categories to a table in the DB (not such a good idea) or memcache. 例如,每隔5分钟左右进行一次肥皂调用,并将类别保存到DB中的表(不是一个好主意)或memcache。

http://memcached.org/ http://memcached.org/

If you can use memcache...here is a ruff example: 如果你可以使用memcache ......这里有一个例子:

$memcache_obj = new Memcache();
$memcache_obj->connect('memcache_host', 11211);

if(!$categories = $memcache_obj->get('soap_categories')) {
 $client = new nusoap_client('http://87.253.63.146/b2b/b2bWS?WSDL', 'wsdl');
 $client->soap_defencoding = 'UTF-8';
 $client->decode_utf8 = false;
 $parametrebi = array('user' => '','brand' => '', 'vat_zone' => 'GEVAT', 'currency' => 'GEL',    'all_items' => 'Y', 'page_num' => '1', 'lines_per_page' => '25');
 $result = $client->call('GetPriceList', $parametrebi, array('return' => 'xsd:string'), "");
 $categories = $result['PriceList']['categories']['category'];
 $memcache_obj->set('soap_categories', $categories)
}


foreach($categories as $category)
{
    echo '<option value="'.$category['!id'].'">'.$category['!name'].'</option>';
}

You can set the expire time on memcache to 1,2,5...ect minuites so the categories will be updated every time the cache expires. 您可以将memcache上的过期时间设置为1,2,5 ... ect minuites,以便每次缓存过期时更新类别。 Other then when the cache expires the lookup time will be less then 5-10ms. 除此之外,当缓存过期时,查找时间将小于5-10ms。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM