powered by nequal
Home » Net_TokyoTyrant » Timeline » 659

Changeset 659 -- 2009-04-13 02:02:48

Author
個々一η•ͺ
Comment
add test code.(data size) fixed bug timeout.

Diffs

Net_TokyoTyrant/trunk/tests/tmp_test.php

@@ -1,4 +1,5 @@
<?php
+ini_set('memory_limit', -1);
require_once dirname(dirname(__FILE__)) . '/Net/TokyoTyrant.php';
$tt = new Net_TokyoTyrant();
@@ -17,7 +18,7 @@
assert(is_string($error) && strlen($error) > 1);
-$tt->connect('localhost', 1978);
+$tt->connect('localhost', 1978, 1000);
assert($tt->vanish() === true);
assert($tt->put($key, $data) === true);
@@ -79,7 +80,18 @@
//assert($tt->ext($extname, $key, $value, Net_TokyoTyrant::RDBXOLCKREC) === $value);
//assert($tt->ext($extname, $key, $value, Net_TokyoTyrant::RDBXOLCKGLB) === $value);
+//big size data
+//$big_data = str_repeat('1', 1024 * 128);
+//for ($i = 0; $i < 1000; $i++) {
+//    assert($tt->put('bigdata', $big_data));
+//}
+//$tt->setTimeout(60);
+$big_data = str_repeat('1', 1024 * 1024 * 32);
+// limit size fllow code is error.... fummm....
+//$big_data = str_repeat('1', 1024 * 1024 * 33);
+assert($tt->put('bigdata', $big_data));
+
assert($tt->sync() === true);
assert(is_array($tt->size()));
assert(is_array($tt->rnum()));

Net_TokyoTyrant/trunk/Net/TokyoTyrant.php

@@ -13,6 +13,8 @@
$socket;
private
$errorNo, $errorMessage;
+    private
+      $socket_timeout;
const RDBXOLCKNON = 0;
const RDBXOLCKREC = 1;
@@ -21,13 +23,24 @@
public function connect($server, $port, $timeout = 10)
{
$this->close();
-        $this->socket = @fsockopen($server,$port, $this->errorNo, $errorMessage);
+        $this->socket = @fsockopen($server,$port, $this->errorNo, $errorMessage, $timeout);
if (! $this->socket) {
throw new Net_TokyoTyrantNetworkException(sprintf('%s, %s', $this->errorNo, $errorMessage));
}
$this->connect = true;
}
+    public function setTimeout($timeout)
+    {
+        $this->socket_timeout = $timeout;
+        stream_set_timeout($this->socket, $timeout);
+    }
+
+    public function getTimeout()
+    {
+        return $this->socket_timeout;
+    }
+
public function close()
{
if ($this->connect) {