Diffs
Net_TokyoTyrant/trunk/tests/nomal_test.php
@@ -1,114 +0,0 @@
-<?php
-ini_set('memory_limit', -1);
-require_once dirname(dirname(__FILE__)) . '/Net/TokyoTyrant.php';
-require_once dirname(dirname(__FILE__)) . '/Net/TokyoTyrant/Table.php';
-
-$tt = new Net_TokyoTyrant();
-$key = 'keytest';
-$data = 'the test data';
-$key2 = 'keytest2';
-$data2 = 'the test2 data';
-$count_key = 'count';
-$extname = 'echo';
-$error = null;
-try {
- $tt->connect('dummy', 1978);
-} catch (Net_TokyoTyrantException $e) {
- $error = $e->getMessage();
-}
-assert(is_string($error) && strlen($error) > 1);
-
-
-$tt->connect('localhost', 1978, 1000);
-
-assert($tt->vanish() === true);
-
-assert($tt->put($key, $data) === true);
-$getdata = $tt->get($key);
-assert($getdata === $data);
-
-assert($tt->putkeep($key, $data . 'keep') === false);
-$getdata = $tt->get($key);
-assert($getdata === $data);
-$tt->out($key);
-assert($tt->putkeep($key, $data . 'keep') === true);
-$getdata = $tt->get($key);
-assert($getdata === $data . 'keep');
-
-assert($tt->put($key, $data) === true);
-$getdata = $tt->get($key);
-assert($getdata === $data);
-assert($tt->putcat($key, $data) === true);
-$getdata = $tt->get($key);
-assert($getdata === $data . $data);
-
-
-assert($tt->put($key, $data) === true);
-assert($tt->putrtt($key, $data, 2) === true);
-$getdata = $tt->get($key);
-assert($getdata === substr($data, strlen($data) - 2, 2));
-
-
-assert($tt->out($key) === true);
-$getdata = $tt->get($key);
-assert($getdata === false);
-
-assert($tt->put($key, $data));
-assert($tt->put($key2, $data2));
-assert(count($tt->mget(array($key, $key2))) === 2);
-assert(count($tt->fwmkeys('key', 2)) === 2);
-assert($tt->vsize($key) === strlen($data));
-assert($tt->vanish() === true);
-assert($tt->iterinit() === true);
-assert($tt->iternext() === false);
-
-assert($tt->put($key, $data));
-assert($tt->iterinit() === true);
-assert($tt->iternext() === $key);
-assert($tt->iternext() === false);
-
-assert($tt->addint($count_key, 1) === 1);
-assert($tt->addint($count_key, 2) === 3);
-assert($tt->addint($count_key, -2) === 1);
-assert($tt->putint($count_key, 1));
-assert($tt->getint($count_key) === 1);
-assert($tt->addint($count_key, 1) === 2);
-assert($tt->getint($count_key) === 2);
-assert($tt->addint($count_key, -3) === -1);
-
-//$value = 'data';
-//assert($tt->ext($extname, $key, $value) === $value);
-//assert($tt->ext($extname, $key, $value, Net_TokyoTyrant::RDBXOLCKNON) === $value);
-//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()));
-
-assert($tt->copy('/tmp/test.net_tokyotyrant.db') === true);
-assert(file_exists('/tmp/test.net_tokyotyrant.db') === true);
-assert(strlen($tt->stat()) > 1);
-
-
-assert($tt->optimize('') === true);
-assert($tt->copy('/tmp/test.net_tokyotyrant.db') === true);
-assert($tt->vanish() === true);
-
-$tt->close();
-$test_data = array();
-$test_data[] = array('name' => 'Alex Low', 'vehicle' => 'silvana', 'age' => 29);
-$test_data[] = array('name' => 'Claus Valca', 'vehicle' => 'vanship', 'age' => 15);
-
Net_TokyoTyrant/trunk/tests/normal_test.php
@@ -0,0 +1,114 @@
+<?php
+ini_set('memory_limit', -1);
+require_once dirname(dirname(__FILE__)) . '/Net/TokyoTyrant.php';
+require_once dirname(dirname(__FILE__)) . '/Net/TokyoTyrant/Table.php';
+
+$tt = new Net_TokyoTyrant();
+$key = 'keytest';
+$data = 'the test data';
+$key2 = 'keytest2';
+$data2 = 'the test2 data';
+$count_key = 'count';
+$extname = 'echo';
+$error = null;
+try {
+ $tt->connect('dummy', 1978);
+} catch (Net_TokyoTyrantException $e) {
+ $error = $e->getMessage();
+}
+assert(is_string($error) && strlen($error) > 1);
+
+
+$tt->connect('localhost', 1978, 1000);
+
+assert($tt->vanish() === true);
+
+assert($tt->put($key, $data) === true);
+$getdata = $tt->get($key);
+assert($getdata === $data);
+
+assert($tt->putkeep($key, $data . 'keep') === false);
+$getdata = $tt->get($key);
+assert($getdata === $data);
+$tt->out($key);
+assert($tt->putkeep($key, $data . 'keep') === true);
+$getdata = $tt->get($key);
+assert($getdata === $data . 'keep');
+
+assert($tt->put($key, $data) === true);
+$getdata = $tt->get($key);
+assert($getdata === $data);
+assert($tt->putcat($key, $data) === true);
+$getdata = $tt->get($key);
+assert($getdata === $data . $data);
+
+
+assert($tt->put($key, $data) === true);
+assert($tt->putrtt($key, $data, 2) === true);
+$getdata = $tt->get($key);
+assert($getdata === substr($data, strlen($data) - 2, 2));
+
+
+assert($tt->out($key) === true);
+$getdata = $tt->get($key);
+assert($getdata === false);
+
+assert($tt->put($key, $data));
+assert($tt->put($key2, $data2));
+assert(count($tt->mget(array($key, $key2))) === 2);
+assert(count($tt->fwmkeys('key', 2)) === 2);
+assert($tt->vsize($key) === strlen($data));
+assert($tt->vanish() === true);
+assert($tt->iterinit() === true);
+assert($tt->iternext() === false);
+
+assert($tt->put($key, $data));
+assert($tt->iterinit() === true);
+assert($tt->iternext() === $key);
+assert($tt->iternext() === false);
+
+assert($tt->addint($count_key, 1) === 1);
+assert($tt->addint($count_key, 2) === 3);
+assert($tt->addint($count_key, -2) === 1);
+assert($tt->putint($count_key, 1));
+assert($tt->getint($count_key) === 1);
+assert($tt->addint($count_key, 1) === 2);
+assert($tt->getint($count_key) === 2);
+assert($tt->addint($count_key, -3) === -1);
+
+//$value = 'data';
+//assert($tt->ext($extname, $key, $value) === $value);
+//assert($tt->ext($extname, $key, $value, Net_TokyoTyrant::RDBXOLCKNON) === $value);
+//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()));
+
+assert($tt->copy('/tmp/test.net_tokyotyrant.db') === true);
+assert(file_exists('/tmp/test.net_tokyotyrant.db') === true);
+assert(strlen($tt->stat()) > 1);
+
+
+assert($tt->optimize('') === true);
+assert($tt->copy('/tmp/test.net_tokyotyrant.db') === true);
+assert($tt->vanish() === true);
+
+$tt->close();
+$test_data = array();
+$test_data[] = array('name' => 'Alex Low', 'vehicle' => 'silvana', 'age' => 29);
+$test_data[] = array('name' => 'Claus Valca', 'vehicle' => 'vanship', 'age' => 15);
+
Net_TokyoTyrant/trunk/Net/TokyoTyrant.php
@@ -198,7 +198,7 @@
{
$result = '';
$res = $this->_read(1);
- $res = unpack('c', $res);
+ $res = unpack('C', $res);
return $res[1];
}
@@ -272,7 +272,7 @@
public function put($key, $value)
{
- $cmd = pack('c*', 0xC8,0x10);
+ $cmd = pack('C*', 0xC8,0x10);
$this->_doRequest($cmd, array((string) $key,(string) $value));
try {
$this->_getResponse();
@@ -284,7 +284,7 @@
public function putkeep($key, $value)
{
- $cmd = pack('c*', 0xC8,0x11);
+ $cmd = pack('C*', 0xC8,0x11);
$this->_doRequest($cmd, array((string) $key,(string) $value));
try {
$this->_getResponse();
@@ -296,7 +296,7 @@
public function putcat($key, $value)
{
- $cmd = pack('c*', 0xC8,0x12);
+ $cmd = pack('C*', 0xC8,0x12);
$this->_doRequest($cmd, array((string) $key,(string) $value));
try {
$this->_getResponse();
@@ -308,7 +308,7 @@
public function putrtt($key, $value, $width)
{
- $cmd = pack('c*', 0xC8,0x13);
+ $cmd = pack('C*', 0xC8,0x13);
$this->_doRequest($cmd, array((string) $key, (string) $value, $width));
try {
$this->_getResponse();
@@ -320,7 +320,7 @@
public function putnr($key, $value)
{
- $cmd = pack('c*', 0xC8,0x18);
+ $cmd = pack('C*', 0xC8,0x18);
$this->_doRequest($cmd, array((string) $key, (string) $value, (int) $width));
try {
$this->_getResponse();
@@ -332,7 +332,7 @@
public function out($key)
{
- $cmd = pack('c*', 0xC8,0x20);
+ $cmd = pack('C*', 0xC8,0x20);
$this->_doRequest($cmd, array((string) $key));
try {
$this->_getResponse();
@@ -344,7 +344,7 @@
public function get($key)
{
- $cmd = pack('c*', 0xC8,0x30);
+ $cmd = pack('C*', 0xC8,0x30);
$this->_doRequest($cmd, array((string) $key));
try {
$this->_getResponse();
@@ -356,7 +356,7 @@
public function mget($keys)
{
- $cmd = pack('c*', 0xC8,0x31);
+ $cmd = pack('C*', 0xC8,0x31);
$values = array();
$values[] = count($keys);
foreach($keys as $key) {
@@ -374,7 +374,7 @@
public function fwmkeys($prefix, $max)
{
- $cmd = pack('c*', 0xC8,0x58);
+ $cmd = pack('C*', 0xC8,0x58);
$this->_doRequest($cmd, array((string) $prefix, (int) $max));
$this->_getResponse();
return $this->_getDataList();
@@ -382,7 +382,7 @@
public function addint($key, $num)
{
- $cmd = pack('c*', 0xC8,0x60);
+ $cmd = pack('C*', 0xC8,0x60);
$this->_doRequest($cmd, array((string) $key, (int) $num));
$this->_getResponse();
return $this->_getInt4();
@@ -402,7 +402,7 @@
public function adddouble($key, $integ, $fract)
{
- $cmd = pack('c*', 0xC8,0x61);
+ $cmd = pack('C*', 0xC8,0x61);
$this->_doRequest($cmd, array((string) $key, (int) $intteg, (int) $fract));
$this->_getResponse();
return array($this->_getInt8(), $this->_getInt8());
@@ -411,7 +411,7 @@
public function ext($extname, $key, $value, $option = 0)
{
- $cmd = pack('c*', 0xC8,0x68);
+ $cmd = pack('C*', 0xC8,0x68);
$this->_doRequest($cmd, array((string) $extname, (int) $option, (string) $key, (string) $value));
$this->_getResponse();
return $this->_getData();
@@ -419,7 +419,7 @@
public function vsize($key)
{
- $cmd = pack('c*', 0xC8,0x38);
+ $cmd = pack('C*', 0xC8,0x38);
$this->_doRequest($cmd, array((string) $key));
$this->_getResponse();
return $this->_getInt4();
@@ -427,7 +427,7 @@
public function iterinit()
{
- $cmd = pack('c*', 0xC8,0x50);
+ $cmd = pack('C*', 0xC8,0x50);
$this->_doRequest($cmd);
$this->_getResponse();
return true;
@@ -435,7 +435,7 @@
public function iternext()
{
- $cmd = pack('c*', 0xC8,0x51);
+ $cmd = pack('C*', 0xC8,0x51);
$this->_doRequest($cmd);
try {
$this->_getResponse();
@@ -447,7 +447,7 @@
public function sync()
{
- $cmd = pack('c*', 0xC8,0x70);
+ $cmd = pack('C*', 0xC8,0x70);
$this->_doRequest($cmd);
$this->_getResponse();
return true;
@@ -455,7 +455,7 @@
public function optimize($param)
{
- $cmd = pack('c*', 0xC8,0x71);
+ $cmd = pack('C*', 0xC8,0x71);
$this->_doRequest($cmd, array((string) $param));
$this->_getResponse();
return true;
@@ -463,7 +463,7 @@
public function vanish()
{
- $cmd = pack('c*', 0xC8,0x72);
+ $cmd = pack('C*', 0xC8,0x72);
$this->_doRequest($cmd);
$this->_getResponse();
return true;
@@ -471,7 +471,7 @@
public function copy($path)
{
- $cmd = pack('c*', 0xC8,0x73);
+ $cmd = pack('C*', 0xC8,0x73);
$this->_doRequest($cmd, array((string) $path));
$this->_getResponse();
return true;
@@ -487,7 +487,7 @@
public function setmst($host, $port)
{
- $cmd = pack('c*', 0xC8,0x78);
+ $cmd = pack('C*', 0xC8,0x78);
$this->_doRequest($cmd, array((string) $host, (int) $port));
$this->_getResponse();
return true;
@@ -495,7 +495,7 @@
public function rnum()
{
- $cmd = pack('c*', 0xC8,0x80);
+ $cmd = pack('C*', 0xC8,0x80);
$this->_doRequest($cmd);
$this->_getResponse();
return $this->_getInt8();
@@ -503,7 +503,7 @@
public function size()
{
- $cmd = pack('c*', 0xC8,0x81);
+ $cmd = pack('C*', 0xC8,0x81);
$this->_doRequest($cmd);
$this->_getResponse();
return $this->_getInt8();
@@ -511,7 +511,7 @@
public function stat()
{
- $cmd = pack('c*', 0xC8,0x88);
+ $cmd = pack('C*', 0xC8,0x88);
$this->_doRequest($cmd);
$this->_getResponse();
return $this->_getValue();
@@ -519,7 +519,7 @@
public function misc($name, $args, $opts = 0)
{
- $cmd = pack('c*', 0xC8, 0x90);
+ $cmd = pack('C*', 0xC8, 0x90);
$data = $cmd . pack('N*', strlen($name), $opts, count($args)) . $name;
foreach ($args as $arg) {