Cassandra\Cluster::connect PHP Method

connect() public method

Creates a new Session instance.
public connect ( string $keyspace = null ) : cassandra\Session
$keyspace string Optional keyspace name
return cassandra\Session Session instance
    function connect($keyspace = null);

Usage Example

コード例 #1
0
 /**
  * Create a new connection instance with the provided configuration
  */
 public function __construct()
 {
     // Set up connection details
     $builder = \Cassandra::cluster();
     // Fetch configured port and set it, if it's provided
     $port = config('cassandra.port');
     if (!empty($port)) {
         $builder->withPort($port);
     }
     // Fetch configured default page size and set it, if it's provided
     $defaultPageSize = config('cassandra.defaultPageSize');
     if (!empty($defaultPageSize)) {
         $builder->withDefaultPageSize($defaultPageSize);
     }
     // Fetch configured default consistency level and set it, if it's provided
     $defaultConsistency = config('cassandra.withDefaultConsistency');
     if (!empty($defaultConsistency)) {
         $builder->withDefaultConsistency($defaultConsistency);
     }
     // Set contact end points
     call_user_func_array([$builder, "withContactPoints"], config('cassandra.contactpoints'));
     // Connect to cluster
     $this->cluster = $builder->build();
     // Create a connect to the keyspace on cluster
     $this->session = $this->cluster->connect(config('cassandra.keyspace'));
 }
All Usage Examples Of Cassandra\Cluster::connect