コード例 #1
0
ファイル: getMemcache.php プロジェクト: v3u3i87/upadd
 protected function connect()
 {
     $this->_memcache = new \Memcache();
     if (!$this->_memcache->connect($this->config['host'], $this->config['port'])) {
         throw new UpaddException("Connect to memcache server failure({$this->config['host']}:{$this->config['port']})!");
     }
 }
コード例 #2
0
ファイル: CacheMemcache.php プロジェクト: kreynen/elmsln
 public function __construct($server = 'localhost', $port = 11211)
 {
     if (empty(self::$memcache)) {
         self::$memcache = new \Memcache();
         self::$memcache->connect($server, $port) or die("Could not connect");
     }
 }
コード例 #3
0
 function connect()
 {
     if (!$this->connected) {
         $this->cache->connect($this->aConf['host'], $this->aConf['port']) or die("Could not connect");
     }
     return $this->connected;
 }
コード例 #4
0
 public function __construct($host = 'localhost', $port = 11211)
 {
     $this->memcache = new \Memcache();
     if (!$this->memcache->connect($host, $port)) {
         throw new \Exception('Unable to connect to Memcache server');
     }
 }
コード例 #5
0
ファイル: Cache.php プロジェクト: tooby93/Resepte
 public function __construct()
 {
     if (class_exists('Memcache')) {
         $this->memcache = new Memcache();
         $config = Vinal::app()->config("cache");
         $this->memcache->connect($config->server, $config->port);
     }
 }
コード例 #6
0
ファイル: Cache.php プロジェクト: krvd/cms-Inji
 /**
  * Try connect to memcache server
  */
 public static function connect()
 {
     if (!self::$connectTrying && class_exists('Memcache', false)) {
         self::$server = new Memcache();
         self::$connected = @self::$server->connect('localhost', 11211);
     }
     self::$connectTrying = true;
 }
コード例 #7
0
ファイル: Redis.Cache.class.php プロジェクト: jc3wish/xlogger
 /**
  * 构造函数
  * @param string $host Redis 服务器的主机名或IP地址或者为服务器组相关信息
  * @param int $port 端口号
  * @param int $timeout 超时时间
  */
 private function __construct($host = 'localhost', $port = 11211, $timeout = 60)
 {
     $this->redis = new \redis();
     if (is_array($host)) {
         $this->redis->connect($host['host'], $host['port']);
     } else {
         $this->redis->connect($host, $port);
     }
 }
コード例 #8
0
ファイル: Memcache.php プロジェクト: laiello/oops-project
 /**
  *
  * @param Oops_Config $config
  */
 public function __construct($config)
 {
     $config = new Oops_Config(array('host' => 'localhost', 'port' => 11211, 'timeout' => 1));
     $this->_m = new Memcache();
     $this->_m->connect($config->host, $config->port, $config->timeout);
     if ($config->compress) {
         $this->_compress = MEMCACHE_COMPRESSED;
     }
 }
コード例 #9
0
ファイル: Memcache.php プロジェクト: pagon/framework
 public function open($path = null, $name = null)
 {
     if (!class_exists('\\Memcache')) {
         throw new \RuntimeException("Use Session\\Memcache need memcache extension installed.");
     }
     $this->memcache = new \Memcache();
     $this->memcache->connect($this->injectors['host'], $this->injectors['port'], $this->injectors['timeout']);
     return true;
 }
コード例 #10
0
ファイル: MemcachedStorage.php プロジェクト: romcok/treeview
 public function __construct($host = 'localhost', $port = 11211, $prefix = '')
 {
     if (!self::isAvailable()) {
         throw new Exception("PHP extension 'memcache' is not loaded.");
     }
     $this->prefix = $prefix;
     $this->memcache = new Memcache();
     $this->memcache->connect($host, $port);
 }
コード例 #11
0
ファイル: Memcache.php プロジェクト: ovr/cacher
 /**
  * @return \Memcache
  */
 public function getInstance()
 {
     if (is_null($this->instance)) {
         $this->instance = new \Memcache();
         $this->instance->connect("localhost", 11211);
         return $this->instance;
     }
     return $this->instance;
 }
コード例 #12
0
 /**
  * construct PhealMemcache,
  * @param array $options optional config array, valid keys are: host, port
  */
 public function __construct($options = array())
 {
     // add options
     if (is_array($options) && count($options)) {
         $this->options = array_merge($this->options, $options);
     }
     $this->memcache = new Memcache();
     $this->memcache->connect($this->options['host'], $this->options['port']);
 }
コード例 #13
0
 public function __construct($server = 'localhost', $port = 11211)
 {
     if (empty(self::$memcache)) {
         if (!class_exists('Memcache')) {
             throw new \Exception('You need to have the php memcached extension');
         }
         self::$memcache = new \Memcache();
         self::$memcache->connect($server, $port) or die("Could not connect");
     }
 }
コード例 #14
0
ファイル: Memcache.php プロジェクト: rosstuck/SessionHandler
 /**
  * Open up the backend
  *
  * @param string $savePath
  * @param string $sessionName
  * @return boolean
  */
 public function open($savePath, $sessionName)
 {
     $this->_backend = new Memcache();
     // Open a persistent or regular connection
     if ($this->_config['persistent']) {
         $this->_backend->pconnect($this->_config['hostname'], $this->_config['port'], $this->_config['timeout_connect']);
     } else {
         $this->_backend->connect($this->_config['hostname'], $this->_config['port'], $this->_config['timeout_connect']);
     }
 }
コード例 #15
0
ファイル: Memcache.php プロジェクト: BertLasker/Catch-design
 /**
  * @param string $sHost = '127.0.0.1'
  * @param int $iPost = 11211
  * @param int $iExpire = 43200
  */
 private function __construct($sHost = '127.0.0.1', $iPost = 11211, $iExpire = 43200)
 {
     $this->sHost = $sHost;
     $this->iPost = $iPost;
     $this->iExpire = 0 < $iExpire ? $iExpire : 43200;
     $this->oMem = new \Memcache();
     if (!$this->oMem->connect($this->sHost, $this->iPost)) {
         $this->oMem = null;
     }
 }
コード例 #16
0
ファイル: Memcache.php プロジェクト: emrahtoy/concept
 /**
  * @param     $host
  * @param int $port
  */
 public function connect($host, $port = 11211)
 {
     try {
         $this->cache = new \Memcache();
         $this->cache->connect($host, $port);
     } catch (\Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         exit;
     }
 }
コード例 #17
0
 /**
  * Singleton instance which means this is redundant
  * @param string $host
  * @param integer|null $port
  * @param integer|null $timeout
  */
 protected function __construct($host, $port = null, $timeout = null)
 {
     if (class_exists('\\Memcache')) {
         $this->memcache = new \Memcache($host, $port, $timeout);
         $this->connected = $this->memcache->connect($host);
     } else {
         // @codeCoverageIgnoreStart
         $this->connected = false;
         // @codeCoverageIgnoreEnd
     }
 }
コード例 #18
0
 /**
  * Creates a new cache_ApcHandler instance
  * @access public
  * @param string $host The host where memcache is listening for connections
  * @param integer $port The port where memcache is listening for connections
  */
 public function __construct($host, $port, $useExceptions = false)
 {
     $this->useExceptions = $useExceptions;
     $this->memcache = new Memcache();
     if (is_null($host)) {
         return;
     }
     if (!$this->memcache->connect($host, $port)) {
         throw new cache_CouldNotConnectException('Could not connect to Memcache server');
     }
 }
コード例 #19
0
 /**
  * Constructor
  *
  * Instantiate the memcache cache object
  *
  * @param  string $host
  * @param  int    $port
  * @throws Exception
  * @return \Pop\Cache\Adapter\Memcached
  */
 public function __construct($host = 'localhost', $port = 11211)
 {
     if (!class_exists('Memcache')) {
         throw new Exception('Error: Memcache is not available.');
     }
     $this->memcache = new \Memcache();
     if (!$this->memcache->connect($host, (int) $port)) {
         throw new Exception('Error: Unable to connect to the memcached server.');
     }
     $this->version = $this->memcache->getVersion();
 }
コード例 #20
0
ファイル: Memcache.php プロジェクト: colibri-fw/cache
 /**
  * @return \Memcache
  */
 private static function getMemcache()
 {
     if (self::$memcache !== null) {
         return self::$memcache;
     }
     $config = self::getConfig();
     self::$defaultExpiration = $config['defaultExpiration'];
     self::$memcache = new \Memcache();
     self::$memcache->connect($config['server'], $config['port']);
     return self::$memcache;
 }
コード例 #21
0
 public function __construct(\Memcache $connection = null)
 {
     if (!extension_loaded('memcache')) {
         throw new MissingExtensionException('PHP extension memcache ist not loaded. You cannot use this cache.');
     }
     if (!$connection) {
         $this->connection = new \Memcache();
         if (!$this->connection->connect('localhost', 11211)) {
             throw new ExtensionException('Cannot connect to memcache on localhost:11211');
         }
     }
 }
コード例 #22
0
ファイル: Memcache.php プロジェクト: Marfuz/c4t_test
 public function _before(TestCase $test)
 {
     if (class_exists('\\Memcache')) {
         $this->memcache = new \Memcache();
         $this->memcache->connect($this->config['host'], $this->config['port']);
     } elseif (class_exists('\\Memcached')) {
         $this->memcache = new \Memcached();
         $this->memcache->addServer($this->config['host'], $this->config['port']);
     } else {
         throw new ModuleConfigException(__CLASS__, 'Memcache classes not loaded');
     }
 }
コード例 #23
0
ファイル: TXMemcache.php プロジェクト: billge1205/biny
 public function __construct($config)
 {
     $this->handler = new Memcache();
     if (isset($config['keep-alive']) && $config['keep-alive']) {
         $fd = $this->handler->pconnect($config['host'], $config['port'], TXConst::minute);
     } else {
         $fd = $this->handler->connect($config['host'], $config['port']);
     }
     if (!$fd) {
         throw new TXException(4004, array($config['host'], $config['port']));
     }
 }
コード例 #24
0
ファイル: Memcache.php プロジェクト: chaoyanjie/MonkeyPHP
 /**
  * 构造方法
  *
  * @param Monkey\App $app
  *
  * @throws \Exception
  */
 public function __construct($app)
 {
     if (!extension_loaded('apc')) {
         new \Exception('会话出错:没有安装Memcache扩展。', 2048);
     }
     $this->app = $app;
     $this->config = $app->config()->getComponentConfig('session', 'memcache');
     $this->handler = new \Memcache();
     if (!$this->handler->connect($this->config['host'], $this->config['port'])) {
         new \Exception('会话出错:Memcache连接失败。', 2048);
     }
     $this->start();
 }
コード例 #25
0
ファイル: PeclMemcache.php プロジェクト: justthefish/hesper
 public function __construct($host = self::DEFAULT_HOST, $port = self::DEFAULT_PORT)
 {
     $this->instance = new \Memcache();
     try {
         try {
             $this->instance->pconnect($host, $port);
         } catch (BaseException $e) {
             $this->instance->connect($host, $port);
         }
         $this->alive = true;
     } catch (BaseException $e) {
         // bad luck.
     }
 }
コード例 #26
0
ファイル: Memcache.php プロジェクト: ZhuJingfa/HuiLib
 protected function __construct($config)
 {
     if (empty($config['host']) || empty($config['port'])) {
         throw new \HuiLib\Error\Exception("Memcache配置信息错误");
     }
     $this->config = $config;
     if (!empty($config['prefix'])) {
         $this->prefix = $config['prefix'];
     }
     $this->connect = new \Memcache();
     if (!$this->connect->connect($config['host'], $config['port'])) {
         throw new \HuiLib\Error\Exception("Memcache连接失败,请确认已安装该拓展");
     }
 }
コード例 #27
0
ファイル: Memcache.php プロジェクト: helsaba/rainloop-webmail
 /**
  * @param string $sHost = '127.0.0.1'
  * @param int $iPost = 11211
  * @param int $iExpire = 43200
  * @param string $sKeyPrefix = ''
  */
 private function __construct($sHost = '127.0.0.1', $iPost = 11211, $iExpire = 43200, $sKeyPrefix = '')
 {
     $this->sHost = $sHost;
     $this->iPost = $iPost;
     $this->iExpire = 0 < $iExpire ? $iExpire : 43200;
     $this->oMem = new \Memcache();
     if (!$this->oMem->connect($this->sHost, $this->iPost)) {
         $this->oMem = null;
     }
     $this->sKeyPrefix = $sKeyPrefix;
     if (!empty($this->sKeyPrefix)) {
         $this->sKeyPrefix = \preg_replace('/[^a-zA-Z0-9_]/', '_', rtrim(trim($this->sKeyPrefix), '\\/')) . '/';
     }
 }
コード例 #28
0
 public function __construct($host = 'localhost', $port = 11211, $prefix = '', Nette\Context $context = NULL)
 {
     if (!self::isAvailable()) {
         throw new \NotSupportedException("PHP extension 'memcache' is not loaded.");
     }
     $this->prefix = $prefix;
     $this->context = $context;
     $this->memcache = new \Memcache();
     Nette\Debug::tryError();
     $this->memcache->connect($host, $port);
     if (Nette\Debug::catchError($msg)) {
         throw new \InvalidStateException($msg);
     }
 }
コード例 #29
0
ファイル: MemcachedStorage.php プロジェクト: kovkus/r-cms
 public function __construct($host = 'localhost', $port = 11211, $prefix = '', IJournal $journal = NULL)
 {
     if (!self::isAvailable()) {
         throw new Nette\NotSupportedException("PHP extension 'memcache' is not loaded.");
     }
     $this->prefix = $prefix;
     $this->journal = $journal;
     $this->memcache = new \Memcache();
     Nette\Diagnostics\Debugger::tryError();
     $this->memcache->connect($host, $port);
     if (Nette\Diagnostics\Debugger::catchError($e)) {
         throw new Nette\InvalidStateException('Memcache::connect(): ' . $e->getMessage(), 0, $e);
     }
 }
コード例 #30
0
ファイル: Memcache.class.php プロジェクト: nonconforme/nreeda
 /**
  * Constructor
  *
  * @param array $connectionData Connection Data parsed by parse_url()
  * @return self
  */
 public function __construct(array $connectionData)
 {
     if (!class_exists("Memcache", false)) {
         error("Memcache Extension not installed - Update your PHP configuration");
     }
     $this->memcache = new Memcache();
     $host = $connectionData["host"];
     $port = arrayValue($connectionData, "port");
     $port = $port ? $port : 11211;
     $connectState = $this->memcache->connect($host, $port);
     if (!$connectState) {
         error("Could not connect to Memcache Server at " . $host . ":" . $port);
     }
 }