/cassis

Pure PHP asynchronous implementation of the Cassandra V4 binary protocol.

Primary LanguagePHPMIT LicenseMIT

PHPinnacle Cassis

Latest Version on Packagist Software License Coverage Status Quality Score Total Downloads

This library is a pure asynchronous PHP implementation of the Cassandra V4 binary protocol. It utilize amphp framework for async operations.

Install

Via Composer

$ composer require phpinnacle/cassis

Basic Usage

<?php

use Amp\Loop;
use PHPinnacle\Cassis\Cluster;
use PHPinnacle\Cassis\Session;
use PHPinnacle\Cassis\Statement;

require __DIR__ . '/vendor/autoload.php';

Loop::run(function () {
    $cluster = Cluster::build('tcp://localhost:9042');
    
    /** @var Session $session */
    $session = yield $cluster->connect('system');

    $statement = new Statement\Simple('SELECT keyspace_name, columnfamily_name FROM schema_columnfamilies');
    $result    = yield $session->execute($statement);

    foreach ($result as $row) {
        printf("The keyspace %s has a table called %s\n", $row['keyspace_name'], $row['columnfamily_name']);
    }

    $session->close();
});

More examples can be found in examples directory. Run it with:

CASSIS_EXAMPLE_DSN=tcp://user:pass@localhost:9042 php example/*

Testing

CASSIS_TEST_DSN=tcp://user:pass@localhost:9042 composer test

Benchmarks

CASSIS_BENCHMARK_DSN=tcp://user:pass@localhost:9042 composer bench

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email dev@phpinnacle.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.