Reusing an open bucket in multiple php pagges

We are using php-fpm with Nginx. Every request to the server is opening a new bucket. The couchbase documentation says not to do this. How can I open a bucket once and then reuse that bucket across all pages?

I have tried the solution proposed here, and it didn’t work:–-how-and-why

I then tried to cache the connection (cache the bucket object and the cluster object) in APC, and it didn’t work either.

Hi, can you tell us what did not work exactly? @brett19 should be able to help you here.

Hey @jjjj,

The trick to reusing server connections is to pass an identical connection string to your new CouchbaseCluster() each time. As long as you are passing an identical connection string and you have php-fpm configured to reuse php instances then your connections will be cached and reused. Note that cacheing your Couchbase object anywhere will not behave as you expect as there are native resources that are needed to back those objects.

Cheers, Brett