/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $gacela = \Gacela\Gacela::instance(); $source = $gacela::createDataSource(array('type' => 'mysql', 'name' => 'db', 'user' => 'gacela', 'password' => 'gacela', 'schema' => 'gacela', 'host' => 'localhost')); $test = $gacela::createDataSource(array('type' => 'mysql', 'name' => 'test', 'user' => 'gacela', 'password' => 'gacela', 'schema' => 'test', 'host' => 'localhost')); $gacela->registerDataSource($source); $gacela->registerDataSource($test); $gacela->registerNamespace('App', __DIR__ . '/../samples/'); $gacela->registerNamespace('Test', __DIR__ . '/Test'); $this->object = $gacela; $this->memcache = new Memcache(); if (!$this->memcache->addServer('127.0.0.1', 11211)) { throw new \Exception($this->memcache->getServerStatus()); } if (is_object($this->memcache)) { $this->memcache->flush(); } }
/** * Connects to a server in connection pool * * @param string $host host ip address or name * @param integer $port Server port * @return boolean True if memcache server was connected */ public function connect($host, $port = 11211) { if ($this->_Memcache->getServerStatus($host, $port) === 0) { if ($this->_Memcache->connect($host, $port)) { return true; } return false; } return true; }
private function _setUpCache() { $frontendOptions = array('lifetime' => 3600, 'automatic_serialization' => true); $backendOptions = array('file_name_prefix' => 'clearhealth', 'hashed_directory_level' => 1, 'cache_dir' => '/tmp/', 'hashed_directory_umask' => 0700); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Registry::set('cache', $cache); $cache = new Memcache(); $cache->connect('127.0.0.1', 11211); $status = $cache->getServerStatus('127.0.0.1', 11211); if ($status === 0) { // memcache server failed, do error trapping? } Zend_Registry::set('memcache', $cache); }
echo "<br />Gearman installed in PHP - Success..."; unset($gearman); /** * 1 & 2 - Include config file, create new client with config */ include 'config/sharedconfig.php'; include 'offLogClient.php'; $loggingClient = new offLogClient($offLogCfg); echo "<br />offLogClient - Success..."; /** * 3 - MySQL connection test */ $mysqli = new mysqli($offLogCfg['database']['host'], $offLogCfg['database']['user'], $offLogCfg['database']['pass'], $offLogCfg['database']['database']); if (mysqli_connect_error()) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo "<br />MySQL - Success... {$mysqli->host_info}"; /** * 4 - Memcache connection test */ $memcache->addServer($offLogCfg['memcache']['ip'], $offLogCfg['memcache']['port']); if (!$memcache->getServerStatus($offLogCfg['memcache']['ip'], $offLogCfg['memcache']['port'])) { die("Connection to memcache failed, is it isntalled and running ?"); } echo "<br />Memcache connection - Success... "; /** * 5 - Fire off logging action 1, userid 1, payload "test string" */ echo "<br />" . $loggingClient->logSimpleAction(1, ACTION_USER_LOGON, 'test string'); echo "<br />logSimpleAction"; echo "<br />Done - tests complete";
$tbl->addHeaderCell($this->objLanguage->languageText("mod_cache_stats", "cache")); $tbl->addHeaderCell(''); $tbl->endHeaderRow(); if (!isset($cache)) { $cache = array(); } foreach ($cache as $servers) { // grab an edit and delete icon $edIcon = $this->objIcon->getEditIcon($this->uri(array('action' => 'editserver', 'id' => $servers['ip'] . ":" . $servers['port'], 'module' => 'cache'))); $delIcon = $this->objIcon->getDeleteIconWithConfirm($servers['ip'], array('module' => 'cache', 'action' => 'deleteserver', 'id' => $servers['ip'] . ":" . $servers['port']), 'cache'); $yesIcon = $this->objIcon->setIcon('greentick'); $yesIcon = $this->objIcon->show(); $noIcon = $this->objIcon->setIcon('redcross'); $noIcon = $this->objIcon->show(); $memcache->addServer($servers['ip'], $servers['port']); if ($memcache->getServerStatus($servers['ip'], $servers['port']) != 0) { $status = $yesIcon; } else { $status = $noIcon; } $extStatsLink = new href($this->uri(array('action' => 'displaystats', 'id' => $servers['ip'] . ":" . $servers['port']), 'cache'), $this->objLanguage->languageText("mod_cache_viewstats", "cache")); $tbl->startRow(); $tbl->addCell($servers['ip']); $tbl->addCell($servers['port']); // get a status icon and show it here $tbl->addCell($status); // get a stats icon $tbl->addCell($extStatsLink->show()); // edit/delete option... $tbl->addCell(''); //$edIcon.$delIcon);
/** * WebVista */ require_once 'WebVista/App.php'; /** * Zend_Loader */ require_once 'Zend/Loader.php'; Zend_Loader::registerAutoLoad(); $frontendOptions = array('lifetime' => 3600, 'automatic_serialization' => true); $backendOptions = array('file_name_prefix' => 'clearhealth', 'hashed_directory_level' => 1, 'cache_dir' => '/tmp/', 'hashed_directory_umask' => 0700); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Registry::set('cache', $cache); $cache = new Memcache(); $cache->connect('127.0.0.1', 11211); $status = $cache->getServerStatus('127.0.0.1', 11211); if ($status === 0) { // memcache server failed, do error trapping? } Zend_Registry::set('memcache', $cache); $config = new Zend_Config_Ini($chAppPath . "/config/app.ini", TESTS_APPLICATION_ENVIRONMENT); Zend_Registry::set('config', $config); try { $dbAdapter = Zend_Db::factory(Zend_Registry::get('config')->database); $dbAdapter->query("SET NAMES 'utf8'"); } catch (Zend_Exception $e) { die($e->getMessage()); } Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter); Zend_Registry::set('dbAdapter', $dbAdapter); unset($chRoot, $chAppPath, $chLibraryPath, $chModelsPath, $chTestsPath, $path);
protected function _setupCache() { /* $frontendOptions = array('lifetime' => 3600, 'automatic_serialization' => true); $backendOptions = array('servers' => array('host' => '127.0.0.1', 'port' => 11211, 'persistent' => true)); $cache = Zend_Cache::factory('Core', 'Memcached', $frontendOptions, $backendOptions); Zend_Registry::set('memcache', $cache); */ $frontendOptions = array('lifetime' => 3600, 'automatic_serialization' => true); $backendOptions = array('file_name_prefix' => 'clearhealth', 'hashed_directory_level' => 1, 'cache_dir' => '/tmp/', 'hashed_directory_umask' => 0700); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Registry::set('cache', $cache); $memcache = new Memcache(); $memcache->connect('127.0.0.1', 11211); $status = $memcache->getServerStatus('127.0.0.1', 11211); if ($status === 0) { // memcache server failed, do error trapping? } Zend_Registry::set('memcache', $memcache); Zend_Registry::set('memcacheStatus', $status); return $this; }