Ejemplo n.º 1
0
 public function __construct($serverName = null)
 {
     if ($serverName != null) {
         $this->server = $serverName;
     }
     parent::__construct();
 }
Ejemplo n.º 2
0
 function __construct()
 {
     parent::__construct();
     $_conf = Vera_Conf::getConf('memcached');
     $this->_connect($_conf['host'], $_conf['port']);
     self::$conf = $_conf;
 }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
 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);
     }
 }
 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);
 }
Ejemplo n.º 6
0
 /**
  * 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']);
     }
 }
Ejemplo n.º 7
0
 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();
     }
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 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']);
     }
 }
 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');
     }
 }
 /**
  * @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);
     }
 }
Ejemplo n.º 12
0
 /**
  * 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));
 }
Ejemplo n.º 13
0
 /**
  * Конструктор. Подключается к серваку мемкэша
  * 
  */
 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');
 }
Ejemplo n.º 14
0
 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);
         }
     }
 }
Ejemplo n.º 15
0
 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);
     }
 }
Ejemplo n.º 16
0
 public function __construct()
 {
     /**
      * check for memcache:  extension_loaded("memcached")
      *
      * These are default memcached settings -- they should
      * work for most users.
      * If they do not work, try changing localhost to 
      * 127.0.0.1 or your server IP address. If none of 
      * those options work, and you are certain memcached
      * is installed and running, contact your web host;
      * some webhosts change the default host parameter 
      * or port
      */
     parent::__construct();
     $this->host = '127.0.0.1';
     $this->port = '11211';
     $this->addserver($this->host, $this->port);
 }
Ejemplo n.º 17
0
 /**
  * Конструктор. Подключается к серваку мемкэша.
  */
 public function __construct($noLock = false)
 {
     parent::__construct();
     $this->_log = new log('memcached/error-%d%m%Y.log', 'a');
     $this->setOption(Memcached::OPT_NO_BLOCK, true);
     $this->setOption(Memcached::OPT_COMPRESSION, false);
     $svk = $GLOBALS[self::SERVERS_VARKEY];
     if (!$svk || !$GLOBALS[$svk]) {
         $svk = 'memcachedServers';
     }
     $servers = $GLOBALS[$svk] or die('Server error: 121');
     foreach ($servers as $s) {
         $this->bIsConnected = $this->addServer($s, 11211);
     }
     if (!$this->bIsConnected) {
         $this->_error('connect');
     }
     $this->server = defined('SERVER') ? SERVER : '';
     $this->noLock = $noLock || (SERVER === 'local' || defined('IS_LOCAL') && IS_LOCAL);
 }
Ejemplo n.º 18
0
 /**
  * construct wrapper
  *
  * @param \stdClass $param
  *
  * @return \chilimatic\lib\Cache\Engine\Memcached
  */
 public function __construct($param = null)
 {
     parent::__construct(isset($param->persistent_id) ? $param->persistent_id : null, isset($param->callback) ? $param->callback : null);
     if (isset($param->server_list)) {
         $server = $param->server_list;
         if (count($server) === 1) {
             $server = array_pop($server);
             $this->setConnected(parent::addServer($server->host, $server->port ?? self::DEFAULT_PORT, isset($server->weight) ? $server->weight : null));
         } else {
             $this->setConnected(parent::addServers($server));
         }
     }
     // Get the Cache Listing
     $this->cacheListing = parent::get('cacheListing');
     if ($this->cacheListing === false) {
         parent::add('cacheListing', array());
         $this->cacheListing = array();
     }
     // check sum for the saving process
     $this->md5Sum = md5(json_encode($this->cacheListing));
 }
Ejemplo n.º 19
0
 public function __construct(array $policy = null)
 {
     if (!extension_loaded('memcached')) {
         throw new LogicException("Error: Please Configure Memcached extension extension first!");
         return false;
     }
     $this->_default_policy = array_merge($this->_default_policy, $policy);
     //parent::__construct( $this->_default_policy['persistent_id'] );
     parent::__construct();
     //是否压缩
     $this->setOption(Memcached::OPT_COMPRESSION, $this->_default_policy['compression']);
     //长连接
     $this->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, $this->_default_policy['persistent']);
     //服务器
     if (!empty($this->_default_policy['servers'])) {
         if (!$this->addServers($this->_default_policy['servers'])) {
             throw new RuntimeException("Error: add cache servers failed, check your servers array.");
         }
     } else {
         throw new LogicException("Error: no cache server add.");
     }
 }
Ejemplo n.º 20
0
 public function __construct($persistent_id = null, $callback = null)
 {
     parent::__construct($persistent_id, $callback);
     $this->persistentId = $persistent_id;
 }
Ejemplo n.º 21
0
 /**
  * Constructor
  */
 public function __construct($servers, $prefix = 'rapid_')
 {
     parent::__construct();
     $this->addServers($servers);
     $this->setOption(\Memcached::OPT_PREFIX_KEY, $prefix);
 }
Ejemplo n.º 22
0
 public function __construct()
 {
     parent::__construct();
     $this->addserver('127.0.0.1', 11211);
 }
Ejemplo n.º 23
0
 /**
  * construct wrapper
  *
  * @param $persistant_key string            
  */
 public function __construct($persistant_key = NULL)
 {
     parent::__construct(is_string($persistant_key) || is_numeric($persistant_key) ? $persistant_key : NULL);
 }
 /**
  * Constructor instantiates and stores Memcached object
  *
  * @param bool $enabled      Are we caching?
  * @param bool $debug        Are we logging?
  * @param null $persistentId Are we persisting?
  */
 public function __construct($enabled, $debug = false, $persistentId = null)
 {
     $this->logging = $debug;
     parent::__construct($enabled, $debug, $persistentId);
 }