Memcached::__construct
(PECL memcached >= 0.1.0)
Create a Memcached instance
Description
Creates a Memcached instance representing the connection to the memcache servers.
Func
Parameters
persistent_idBy default the Memcached instances are destroyed at the end of the request. To create an instance that persists between requests, use
persistent_idto specify a unique ID for the instance. All instances created with the samepersistent_idwill share the same connection.callback- callback(Memcached $memcached, string|null $persistent_id): void
The
callbackparameter is called when the connection is established. It should be a valid PHPcallablethat receive theMemcachedobject as its first parameter, andpersistent_idas its second. connection_strThis parameter is used to pass additional connection options to the memcache servers, such as a server weight in a cluster.
Examples
Creating a Memcached object
<?php
/* Create a regular instance */
$m = new Memcached();
echo get_class($m);
/* Create a persistent instance */
$m2 = new Memcached('story_pool');
$m3 = new Memcached('story_pool');
/* now $m2 and $m3 share the same connection */
?>