我正在尝试使用 phpcassa 将文本文件中的 1000000 条记录加载到Cassandra中。但是在加载过程的中途,我收到了以下错误。
PHP 致命错误:在第 759 行的 /usr/share/php/phpcassa/columnfamily.php 中超过了 30 秒的最大执行时间**
如何增加执行时间?我必须更改任何参数columnfamily.php
吗?请在下面找到我的代码。
<?
require_once('phpcassa/connection.php');
require_once('phpcassa/columnfamily.php');
try {
$servers = array("127.0.0.1:9160");
$pool = new ConnectionPool("Keyspace1", $servers);
$column_family = new ColumnFamily($pool, 'Product');
$cnt=0;
$files = fopen("dump.txt", "r");
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
while (!feof($files)) {
$line = fgets($files);
$keyname="P".$cnt;
$split_line = explode("," , $line);
for ($i=0;$i<count($split_line);$i++) {
//echo $split_line[$i];
$column_family->insert(
$keyname, array(
'code' => $split_line[0] ,
'pname' => $split_line[1] ,
'price' => $split_line[2]
)
);
}
$cnt += 1;
}
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
fclose($files);
$totaltime = ($endtime - $starttime);
echo "$cnt keys loaded in ".$totaltime." seconds";
}
catch (Exception $e)
{
echo 'Exception: ' . $e->getMessage();
}
?>