Skip to content

Constants

All constants live on the global Cassandra class.

Version

php
Cassandra::VERSION;              // the extension version, for example '1.4.1'
Cassandra::CPP_DRIVER_VERSION;   // the linked C/C++ driver version, resolved at runtime
php
printf("driver %s on cpp-driver %s\n", Cassandra::VERSION, Cassandra::CPP_DRIVER_VERSION);

Consistency levels

ConstantReplicas that must answer
Cassandra::CONSISTENCY_ANYAny node, including a hinted handoff. Writes only
Cassandra::CONSISTENCY_ONEOne replica, any datacenter
Cassandra::CONSISTENCY_TWOTwo replicas
Cassandra::CONSISTENCY_THREEThree replicas
Cassandra::CONSISTENCY_QUORUMA quorum across all datacenters
Cassandra::CONSISTENCY_ALLEvery replica
Cassandra::CONSISTENCY_LOCAL_ONEOne replica in the local datacenter
Cassandra::CONSISTENCY_LOCAL_QUORUMA quorum inside the local datacenter
Cassandra::CONSISTENCY_EACH_QUORUMA quorum in every datacenter. Writes only
Cassandra::CONSISTENCY_SERIALFor a lightweight transaction, across datacenters
Cassandra::CONSISTENCY_LOCAL_SERIALFor a lightweight transaction, local datacenter

The cluster default is CONSISTENCY_LOCAL_QUORUM. Change it per statement when a query values latency over freshness. Set cassandra.default_consistency in php.ini to change it for a whole deployment.

php
$cluster = Cassandra::cluster()
    ->withDefaultConsistency(Cassandra::CONSISTENCY_LOCAL_QUORUM)
    ->build();

$rows = $session->execute($statement, [
    'consistency' => Cassandra::CONSISTENCY_LOCAL_ONE,
]);

CONSISTENCY_SERIAL and CONSISTENCY_LOCAL_SERIAL belong in the serial_consistency option, not in consistency. See lightweight transactions.

TLS verification flags

ConstantMeaning
Cassandra::VERIFY_NONEEncrypt only. Do not check the server certificate
Cassandra::VERIFY_PEER_CERTCheck the certificate against the trusted certificates
Cassandra::VERIFY_PEER_IDENTITYAlso check that the identity matches the peer

Combine them with the bitwise or operator:

php
Cassandra::ssl()
    ->withVerifyFlags(Cassandra::VERIFY_PEER_CERT | Cassandra::VERIFY_PEER_IDENTITY)
    ->build();

See TLS and SSL.

Batch types

ConstantMeaning
Cassandra::BATCH_LOGGEDAtomic across partitions, at the cost of a batch log write
Cassandra::BATCH_UNLOGGEDNo batch log
Cassandra::BATCH_COUNTERRequired for counter updates
php
new Cassandra\BatchStatement(Cassandra::BATCH_UNLOGGED);

See batches.

Log levels

ConstantValue in php.ini
Cassandra::LOG_DISABLED
Cassandra::LOG_CRITICALCRITICAL
Cassandra::LOG_ERRORERROR
Cassandra::LOG_WARNWARN
Cassandra::LOG_INFOINFO
Cassandra::LOG_DEBUGDEBUG
Cassandra::LOG_TRACETRACE

The log level is set in php.ini, not in code:

ini
cassandra.log_level = ERROR

See metrics and logging.

CQL type names

String constants used by the collection constructors.

ConstantValue
Cassandra::TYPE_ASCIIascii
Cassandra::TYPE_TEXTtext
Cassandra::TYPE_VARCHARvarchar
Cassandra::TYPE_TINYINTtinyint
Cassandra::TYPE_SMALLINTsmallint
Cassandra::TYPE_INTint
Cassandra::TYPE_BIGINTbigint
Cassandra::TYPE_VARINTvarint
Cassandra::TYPE_COUNTERcounter
Cassandra::TYPE_FLOATfloat
Cassandra::TYPE_DOUBLEdouble
Cassandra::TYPE_DECIMALdecimal
Cassandra::TYPE_BOOLEANboolean
Cassandra::TYPE_BLOBblob
Cassandra::TYPE_INETinet
Cassandra::TYPE_UUIDuuid
Cassandra::TYPE_TIMEUUIDtimeuuid
Cassandra::TYPE_TIMESTAMPtimestamp
php
new Cassandra\Collection(Cassandra::TYPE_TEXT);
new Cassandra\Map(Cassandra::TYPE_UUID, Cassandra::TYPE_INT);

For a composite element type, use the type factory instead.

Static methods

php
Cassandra::cluster(): Cassandra\Cluster\Builder;
Cassandra::ssl(): Cassandra\SSLOptions\Builder;

These are the two entry points to the driver.

Version 1.4. Released under the Apache License 2.0.