Methods summary
public
|
#
__construct( string $keyspace, mixed $servers = NULL, integer $pool_size = NULL, integer $max_retries = phpcassa\Connection\ConnectionPool::DEFAULT_MAX_RETRIES , integer $send_timeout = 5000, integer $recv_timeout = 5000, integer $recycle = phpcassa\Connection\ConnectionPool::DEFAULT_RECYCLE , mixed $credentials = NULL, boolean $framed_transport = true )
Constructs a ConnectionPool.
Constructs a ConnectionPool.
Parameters
- $keyspace
string $keyspace the keyspace all connections will use
- $servers
mixed $servers an array of strings representing the servers to open connections to.
Each item in the array should be a string of the form 'host' or 'host:port'. If
a port is not given, 9160 is assumed. If $servers is NULL, 'localhost:9160' will
be used.
- $pool_size
integer $pool_size the number of open connections to keep in the pool. If $pool_size is
left as NULL, max(5, count($servers) * 2) will be used.
- $max_retries
integer $max_retries how many times an operation should be retried before throwing a
MaxRetriesException. Using 0 disables retries; using -1 causes unlimited
retries. The default is 5.
- $send_timeout
integer $send_timeout the socket send timeout in milliseconds. Defaults to 5000.
- $recv_timeout
integer $recv_timeout the socket receive timeout in milliseconds. Defaults to 5000.
- $recycle
integer $recycle after this many operations, a connection will be automatically closed
and replaced. Defaults to 10,000.
- $credentials
mixed $credentials if using authentication or authorization with Cassandra, a username
and password need to be supplied. This should be in the form array("username"
=> username, "password" => password)
- $framed_transport
boolean $framed_transport whether to use framed transport or buffered transport. This
must match Cassandra's configuration. In Cassandra 0.7, framed transport is the
default. The default value is true.
|
public
|
#
fill( )
Adds connections to the pool until $pool_size connections are in the
pool.
Adds connections to the pool until $pool_size connections are in the
pool.
|
public
phpcassa\Connection\ConnectionWrapper
|
#
get( )
Retrieves a connection from the pool.
Retrieves a connection from the pool.
If the pool has fewer than $pool_size connections in it, a new connection
will be created.
Returns
phpcassa\Connection\ConnectionWrapper a connection
|
public
|
#
return_connection( phpcassa\Connection\ConnectionWrapper $connection )
Returns a connection to the pool.
Returns a connection to the pool.
Parameters
- $connection
phpcassa\Connection\ConnectionWrapper $connection
|
public
mixed
|
#
describe_keyspace( )
Gets the keyspace description, caching the results for later lookups.
Gets the keyspace description, caching the results for later lookups.
Returns
mixed
|
public
|
#
dispose( )
Closes all connections in the pool.
Closes all connections in the pool.
|
public
|
#
close( )
Closes all connections in the pool.
Closes all connections in the pool.
|
public
array
|
#
stats( )
Returns information about the number of opened connections, failed
operations, and recycled connections.
Returns information about the number of opened connections, failed
operations, and recycled connections.
Returns
array Stats in the form array("failed" => failure_count, "created" =>
creation_count, "recycled" => recycle_count)
|
public
mixed
|
#
call( )
Performs a Thrift operation using a connection from the pool. The first
argument should be the name of the function. The following arguments should be
the arguments for that Thrift function.
Performs a Thrift operation using a connection from the pool. The first
argument should be the name of the function. The following arguments should be
the arguments for that Thrift function.
If the connect fails with any exception other than a NotFoundException, the
connection will be closed and replaced in the pool. If the Exception is suitable
for retrying the operation (TimedOutException, UnavailableException,
TTransportException), the operation will be retried with a new connection after
an exponentially increasing backoff is performed.
To avoid automatic retries, create a ConnectionPool with the $max_retries
argument set to 0.
In general, this method should not be used by users of the library.
It is primarily intended for internal use, but is left exposed as an open
workaround if needed.
Returns
mixed
|