Couchbase Bucket Cache AdapterEdit this page
This adapter stores the values in-memory using one (or more) Couchbase server instances. Unlike the APCu adapter, and similarly to the Memcached adapter, it is not limited to the current server's shared memory; you can store contents independent of your PHP environment. The ability to utilize a cluster of servers to provide redundancy and/or fail-over is also available.
Requirements: The Couchbase PHP extension as well as a Couchbase server
must be installed, active, and running to use this adapter. Version
less than 3.0 of the Couchbase PHP extension is required for this adapter.
This adapter expects a Couchbase Bucket instance to be passed as the first parameter. A namespace and default cache lifetime can optionally be passed as the second and third parameters:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
use Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter; $cache = new CouchbaseBucketAdapter( // the client object that sets options and adds the server instance(s) $client, // the name of bucket $bucket, // a string prefixed to the keys of the items stored in this cache $namespace, // the default lifetime (in seconds) for cache items that do not define their // own lifetime, with a value 0 causing items to be stored indefinitely $defaultLifetime );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter; // pass a single DSN string to register a single server with the client $client = CouchbaseBucketAdapter::createConnection( 'couchbase://localhost' // the DSN can include config options (pass them as a query string): // 'couchbase://localhost:11210?operationTimeout=10' // 'couchbase://localhost:11210?operationTimeout=10&configTimeout=20' ); // pass an array of DSN strings to register multiple servers with the client $client = CouchbaseBucketAdapter::createConnection([ 'couchbase://10.0.0.100', 'couchbase://10.0.0.101', 'couchbase://10.0.0.102', // etc... ]); // a single DSN can define multiple servers using the following syntax: // host[hostname-or-IP:port] (where port is optional). Sockets must include a trailing ':' $client = CouchbaseBucketAdapter::createConnection( 'couchbase:?host[localhost]&host[localhost:12345]' );
helper method also accepts an array of options as its second argument. The
expected format is an associative array of
key => value pairs representing
option names and their respective values:
1 2 3 4 5 6 7 8 9 10 11 12 13
use Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter; $client = CouchbaseBucketAdapter::createConnection( // a DSN string or an array of DSN strings , // associative array of configuration options [ 'username' => 'xxxxxx', 'password' => 'yyyyyy', 'configTimeout' => '100', ] );
Username for connection
Password of connection
- The operation timeout (in microseconds) is the maximum amount of time the library will wait for an operation to receive a response before invoking its callback with a failure status.
- How long (in microseconds) the client will wait to obtain the initial configuration.
- Per-node configuration timeout (in microseconds).
- The I/O timeout (in microseconds) for HTTP requests to Couchbase Views API.
- The I/O timeout (in microseconds) for HTTP queries (management API).
- Config refresh throttling Modify the amount of time (in microseconds) before the configuration error threshold will forcefully be set to its maximum number forcing a configuration refresh.
- Idling/Persistence for HTTP bootstrap (in microseconds).
- The time (in microseconds) the client will wait between repeated probes to a given server.
- The time (in microseconds) the client will spend sending repeated probes to a given key's vBucket masters and replicas before they are deemed not to have satisfied the durability requirements.