tatikoma / react-cassandra
Performant pure-PHP CQL (Cassandra) async (ReactPHP) library
dev-master
2018-01-11 11:59 UTC
Requires
- php: >=5.4.0
- clue/block-react: ^1.1
- evenement/evenement: ^2.0
- react/event-loop: ~0.4
- react/promise: ~2.2
- react/stream: ^0.4.4
This package is not auto-updated.
Last update: 2025-03-29 01:20:02 UTC
README
Performant pure-PHP CQL v4 (Cassandra) async (ReactPHP) library.
Library is not ready for production and much of functional is not implemented yet.
Installation
php composer.phar require tatikoma/react-cassandra:dev-master
Example usage (async mode):
require_once 'vendor/autoload.php'; $loop = React\EventLoop\Factory::create(); $cluster = new \Tatikoma\React\Cassandra\Async\Cluster($loop, [ ['host' => '127.0.0.1'], ['host' => '127.0.0.2'], ['host' => '127.0.0.3'], ['host' => '127.0.0.4'], ]); $cluster->connect('test')->then(function() use($cluster){ print "Connected to cluster keyspace test\n"; $uuid = '00000000-0000-0000-0000-000000000000'; return $cluster->query(' SELECT * FROM example WHERE id = :id ',[ 'id' => new \Tatikoma\React\Cassandra\Type\UUID($uuid), ]); })->then(function($response){ print "Query successfull, got " . count($response->results) . " rows:\n"; foreach($response as $row){ var_dump($row); } }, function(\Tatikoma\React\Cassandra\Protocol\ErrorFrame $reason){ print "Query failed: " . $reason->errorString . "\n"; }); $loop->run();
Example usage (sync mode):
require_once 'vendor/autoload.php'; $cluster = new \Tatikoma\React\Cassandra\Cluster([ ['host' => '127.0.0.1'], ['host' => '127.0.0.2'], ['host' => '127.0.0.3'], ['host' => '127.0.0.4'], ]); $cluster->connect('test'); $uuid = '00000000-0000-0000-0000-000000000000'; $response = $cluster->query(' SELECT * FROM example WHERE id = :id ',[ 'id' => new \Tatikoma\React\Cassandra\Type\UUID($uuid), ]); print "got " . count($response->results) . " rows:\n"; foreach($response as $row){ var_dump($row); }