Skip to content

Commit 25a23d1

Browse files
author
Bulat Shakirzyanov
committed
add a note about persistent sessions
1 parent d00f6cd commit 25a23d1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

features/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ $session = $cluster->connect();
2020

2121
After the initial connection to one of the hosts specified via `withContactPoints()` succeeded, the driver discovers the addresses and connects to all members of the cluster automatically. You can also see the nodes that the driver discovered by running `SELECT * FROM system.peers`.
2222

23+
### Persistent sessions
24+
25+
In order to limit the startup time and total number of connections to a Cassandra cluster, the PHP Driver enabled persistent sessions by default. All cluster and sessions using the same initial configuration will be shared across requests when persistent sessions are enabled. You can toggle this setting using [`Cassandra\Cluster\Builder::withPersistentSessions()`](http://datastax.github.io/php-driver/api/class/Cassandra/Cluster/Builder/#with-persistent-sessions).
26+
27+
```php
28+
<?php
29+
30+
$cluster = Cassandra::cluster()
31+
->withPersistentSessions(false)
32+
->build();
33+
$session = $cluster->connect();
34+
```
35+
36+
Note that disabling persistent sessions will cause significant slow down of cluster initialization as the connections will be forced to get re-established for every request.
37+
38+
Once persistent sessions are enabled, you can view how many of them are currently active. They will be exposed in the Cassandra extension section of `phpinfo()`.
39+
2340
### Configuring load balancing policy
2441

2542
PHP Driver comes with a variety of load balancing policies. By default it uses a combination of token aware data center round robin.

0 commit comments

Comments
 (0)