예제 #1
0
파일: test.php 프로젝트: lucmichalski/fae
use Thrift\Exception\TProtocolException;
use fun\rpc\FunServantClient;
use fun\rpc\Context;
use fun\rpc\TCacheMissed;
use fun\rpc\TMongoMissed;
use fun\rpc\TMemcacheData;
try {
    $sock = new TSocketPool(array('localhost'), array(9001));
    $sock->setDebug(0);
    $sock->setSendTimeout(4000);
    $sock->setRecvTimeout(4000);
    $sock->setNumRetries(1);
    $transport = new TBufferedTransport($sock, 1024, 1024);
    $protocol = new TBinaryProtocol($transport);
    // get our client
    $client = new FunServantClient($protocol);
    $transport->open();
    $ctx = new Context(array('reason' => "phptest", 'rid' => hexdec(uniqid())));
    // ping
    $return = $client->ping($ctx);
    echo "[Client] ping received: ", $return, "\n";
    // id.next
    echo "[Client] id_next received:", $client->id_next($ctx), "\n";
    echo "[Client] id_next received:", $client->id_next($ctx), "\n";
    echo "[Client] id_next_with_tag received:", $client->id_next_with_tag($ctx, 5), "\n";
    echo "[Client] id_next_with_tag received:", $client->id_next_with_tag($ctx, 10), "\n";
    $id = $client->id_next_with_tag($ctx, 18);
    list($ts, $tag, $wid, $seq) = $client->id_decode($ctx, $id);
    echo "{$ts} {$tag} {$wid} {$seq}\n";
    // lc
    echo '[Client] lc_set received: ', $client->lc_set($ctx, 'hello-php-lc', 'world 世界'), "\n";
예제 #2
0
파일: mysql.php 프로젝트: lucmichalski/fae
use Thrift\Exception\TProtocolException;
use fun\rpc\FunServantClient;
use fun\rpc\Context;
use fun\rpc\TCacheMissed;
use fun\rpc\TMongoMissed;
use fun\rpc\TMemcacheData;
try {
    $sock = new TSocketPool(array('localhost', 'localhost'), array(9001, 9011));
    $sock->setDebug(1);
    $sock->setSendTimeout(4000);
    $sock->setRecvTimeout(4000);
    $sock->setNumRetries(1);
    $transport = new TBufferedTransport($sock, 1024, 1024);
    $protocol = new TBinaryProtocol($transport);
    // get our client
    $client = new FunServantClient($protocol);
    $transport->open();
    $ctx = new Context(array('rid' => hexdec(uniqid()), 'reason' => 'call.init.121'));
    // mysql select multiple rows
    echo "\nDEMO SELECT\n";
    echo "===============================\n";
    $rows = $client->my_query($ctx, 'UserShard', 'UserInfo', 1, 'SELECT * from UserInfo where uid>?', array(1), '');
    echo $rows->rowsAffected, ':rowsAffected, ', $rows->lastInsertId, ':lastInsertId, rows:', PHP_EOL;
    print_r($rows);
    // mysql query cache
    $rows = $client->my_query($ctx, 'UserShard', 'UserInfo', 1, 'SELECT * from UserInfo where uid=?', array(1), 'UserInfo:1');
    $rows = $client->my_query($ctx, 'UserShard', 'UserInfo', 1, 'SELECT * from UserInfo where uid=?', array(1), 'UserInfo:1');
    print_r($rows);
    // mysql update
    echo "\nDEMO UPDATE\n";
    echo "===============================\n";