iwai/elasticsearch-guzzle5connection
最新稳定版本:1.0.1
Composer 安装命令:
composer require iwai/elasticsearch-guzzle5connection
包简介
README 文档
README
Async support for elasticsearch-php
Caution!!!
- Unsupported
pingmethod - Unsupported
existsmethod - Unsupported logging
Install
{ "require": { "elasticsearch/elasticsearch": "~1.0", "iwai/elasticsearch-guzzle5connection": "~1.0" } }
Example
Transparent async request
use Elasticsearch\Client as ESClient; $client = new ESClient([ 'hosts' => [ '127.0.0.1:9200' ], 'connectionClass' => '\Iwai\Elasticsearch\Guzzle5Connection', 'serializerClass' => '\Iwai\Elasticsearch\FutureSerializer' ]); $response = $client->get([ 'index' => 'index_name', 'type' => 'type', 'id' => '1', ]); echo $response['hits']['total'];
Explicit wait request
use Elasticsearch\Client as ESClient; $client = new ESClient([ 'hosts' => [ '127.0.0.1:9200' ], 'connectionClass' => '\Iwai\Elasticsearch\Guzzle5Connection', 'serializerClass' => '\Iwai\Elasticsearch\FutureSerializer' ]); $future = $client->get([ 'index' => 'index_name', 'type' => 'type', 'id' => '1', ]); $response = $future->wait(); echo $response['hits']['total'];
Promise style
use Elasticsearch\Client as ESClient; $client = new ESClient([ 'hosts' => [ '127.0.0.1:9200' ], 'connectionClass' => '\Iwai\Elasticsearch\Guzzle5Connection', 'serializerClass' => '\Iwai\Elasticsearch\FutureSerializer' ]); $future = $client->get([ 'index' => 'index_name', 'type' => 'type', 'id' => '1', ]); $futureData->then(function ($response) { echo $response['hits']['total']; });
With RingPHP
use React\EventLoop; use WyriHaximus\React\RingPHP\HttpClientAdapter; use Elasticsearch\Client as ESClient; $loop = EventLoop\Factory::create(); $client = new ESClient([ 'hosts' => [ '127.0.0.1:9200' ], 'connectionClass' => '\Iwai\Elasticsearch\Guzzle5Connection', // required 'serializerClass' => '\Iwai\Elasticsearch\FutureSerializer', // required 'connectionParams' => [ 'ringphp_handler' => new HttpClientAdapter($loop) ] // optional ]); $futureData = $client->get([ 'index' => 'index_name', 'type' => 'type', 'id' => '1', ]); $futureData->then(function ($response) { echo $response['hits']['total']; }); $loop->run();
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2014-12-20