本文整理汇总了PHP中Memcached::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcached::__construct方法的具体用法?PHP Memcached::__construct怎么用?PHP Memcached::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcached
的用法示例。
在下文中一共展示了Memcached::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($serverName = null)
{
if ($serverName != null) {
$this->server = $serverName;
}
parent::__construct();
}
示例2:
function __construct()
{
parent::__construct();
$_conf = Vera_Conf::getConf('memcached');
$this->_connect($_conf['host'], $_conf['port']);
self::$conf = $_conf;
}
示例3: __construct
public function __construct()
{
parent::__construct('internal.makerspace.se');
// Do NOT spawn millions of connections...
if (!count($this->getServerList())) {
parent::addServer('127.0.0.1', 11211);
}
}
示例4: __construct
public function __construct(&$system)
{
parent::__construct();
$cfg = explode(':', __CFG::MEMCACHE);
if ($this->addServer($cfg[0], $cfg[1])) {
trigger_error('Connect Mcache Server Fail!', E_USER_ERROR);
}
}
示例5: __construct
public function __construct($host, $port, $id = 'story_pool')
{
parent::__construct($id);
if (!parent::addServer($host, $port)) {
throw new Exception("Could not connect memcached server {$host}:{$port}." . "\n" . 'Error code: ' . parent::getResultCode() . "\n" . ' Error message: ' . parent::getResultMessage());
}
parent::setOption(Memcached::OPT_BINARY_PROTOCOL, true);
}
示例6: __construct
/**
* Construct
* @param array $options the config options
*/
public function __construct(array $options = [])
{
// call the parent with the cache pool name
parent::__construct(self::MEMCACHED_POOL);
// add the memcache server pool
if (!$this->getServerList() && isset($options['memcached']['server'])) {
$this->set_server_pool($options['memcached']['server']);
}
}
示例7: __construct
public function __construct()
{
parent::__construct();
$cfg = explode(':', __CFG::MEMCACHE);
if (!$this->addServer($cfg[0], $cfg[1])) {
trigger_error('Memcache Connect Fail', E_USER_ERROR);
} else {
$this->prefix();
}
}
示例8: __construct
public function __construct($persistent_id = 'xxam', $server_host = 'localhost', $server_port = 11211, $options = array())
{
$this->persistent_id = $persistent_id;
$this->server_host = $server_host;
$this->server_port = $server_port;
$this->options = $options;
parent::__construct($persistent_id);
$this->addServer($this->server_host, $this->server_port);
$this->setOptions($this->options);
}
示例9: __construct
public function __construct($config)
{
if (!extension_loaded('memcached')) {
die('Memcached extension that required by Driver memcached is not available.');
}
parent::__construct();
foreach ($config['server'] as $server) {
$this->addServer($server['host'], $server['port'], $server['persistent']);
}
}
示例10: __construct
public function __construct($host = Memcached::DEFAULT_HOST, $port = Memcached::DEFAULT_PORT, $buffer = Memcached::DEFAULT_BUFFER)
{
if (PinbaClient::isEnabled()) {
PinbaClient::me()->timerStart('memcached_' . $host . '_' . $port . '_connect', array('memcached_connect' => $host . '_' . $port));
}
parent::__construct($host, $port, $buffer);
if (PinbaClient::isEnabled()) {
PinbaClient::me()->timerStop('memcached_' . $host . '_' . $port . '_connect');
}
}
示例11: __construct
/**
* @inheritdoc
* @codeCoverageIgnore
*/
public function __construct($prefix = '', $host = 'localhost', $port = 11211, $persistent_id = null)
{
parent::__construct($persistent_id);
$this->host = $host;
$this->port = 11211;
$this->addServer($this->host, $this->port);
$this->prefix = $prefix;
if (empty($prefix)) {
$this->prefix = (string) rand(100, 999);
}
}
示例12:
/**
* KitMemcached Constructor
* @param $key_prefix
* @param MemcachedConnector $connector
* @internal param bool $safemode
* @return \Kit\DB\Memcached\Memcached
*/
function __construct($key_prefix, MemcachedConnector $connector)
{
// Construct parent
parent::__construct();
// Set param prefix
self::$_prefix = crc32($key_prefix);
// Inst: Object Connector class
self::$_instConnector = $connector;
// Void: Apply Connector container to base Memcached
$this->applyConnector($this, self::$_instConnector);
// set the key prefix.
$this->setOptions(array(self::OPT_PREFIX_KEY => self::$_prefix));
}
示例13: die
/**
* Конструктор. Подключается к серваку мемкэша
*
*/
function __construct()
{
parent::__construct();
if (!($server = $GLOBALS['memcachedSessionServer'])) {
// В /classes/config.php добавляем:
// $memcachedSessionServer = 'localhost';
if (!($server = $GLOBALS['memcachedServers'][0])) {
die('Не найдены сервера Memcached');
}
}
$this->bIsConnected = $this->addServer($server, 11211);
$this->setOption(self::OPT_PREFIX_KEY, SERVER);
$this->_log = new log('sessions/error-%d%m%Y.log', 'a');
}
示例14:
function __construct($persistent_id = null)
{
if (is_null($persistent_id)) {
parent::__construct();
$this->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
if (!count($this->getServerList())) {
$this->addServers(\config\Conf::$memcachedserver);
}
} else {
parent::__construct($persistent_id);
$this->setOption(\Memcached::OPT_PREFIX_KEY, $persistent_id);
$this->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
if (!count($this->getServerList())) {
$this->addServers(\config\Conf::$memcachedserver);
}
}
}
示例15: __construct
public function __construct($persistentId = '-')
{
parent::__construct($persistentId);
$serverList = $this->getServerList();
if (empty($serverList)) {
$this->setOption(\Memcached::OPT_PREFIX_KEY, 'sndsgd-');
$this->setOption(\Memcached::OPT_RECV_TIMEOUT, 1000);
$this->setOption(\Memcached::OPT_SEND_TIMEOUT, 1000);
$this->setOption(\Memcached::OPT_TCP_NODELAY, true);
$this->setOption(\Memcached::OPT_SERVER_FAILURE_LIMIT, 50);
$this->setOption(\Memcached::OPT_CONNECT_TIMEOUT, 500);
$this->setOption(\Memcached::OPT_RETRY_TIMEOUT, 300);
$this->setOption(\Memcached::OPT_REMOVE_FAILED_SERVERS, true);
$this->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$this->addServer('127.0.0.1', 11211, 1);
}
}