Ejemplo n.º 1
0
 /**
  * Gets Memcached instance if exists, otherwise creates a new instance.
  * 
  * @return Memcached instance.
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 2
0
 public static function init()
 {
     #-------------------------------------------------------------------------------
     if (self::$instance === NULL) {
         #-------------------------------------------------------------------------------
         try {
             #-------------------------------------------------------------------------------
             Debug("[system/classes/auto/CacheManager.class.php]: Start initializing cache system.");
             #-------------------------------------------------------------------------------
             if (Extension_Loaded(MemcachedCache::EXT_NAME) && File_Exists(SPrintF('%s/.memcached', SYSTEM_PATH))) {
                 #-------------------------------------------------------------------------------
                 Debug('[system/classes/auto/CacheManager.class.php]: Force load MemcachedCache');
                 #-------------------------------------------------------------------------------
                 self::$instance = MemcachedCache::getInstance();
                 #-------------------------------------------------------------------------------
             } else {
                 if (Extension_Loaded(APCCache::EXT_NAME)) {
                     #-------------------------------------------------------------------------------
                     Debug('[system/classes/auto/CacheManager.class.php]: Load APCCache');
                     #-------------------------------------------------------------------------------
                     self::$instance = APCCache::getInstance();
                     #-------------------------------------------------------------------------------
                 } else {
                     if (Extension_Loaded(MemcachedCache::EXT_NAME)) {
                         #-------------------------------------------------------------------------------
                         Debug('[system/classes/auto/CacheManager.class.php]: Load MemcachedCache');
                         #-------------------------------------------------------------------------------
                         self::$instance = MemcachedCache::getInstance();
                         #-------------------------------------------------------------------------------
                     } else {
                         #-------------------------------------------------------------------------------
                         throw new Exception("Any supported cache not installed in your sysytem.");
                     }
                 }
             }
             #-------------------------------------------------------------------------------
             Debug("Cache system has been initialized.");
             #-------------------------------------------------------------------------------
         } catch (Exception $e) {
             #-------------------------------------------------------------------------------
             Debug("Cache system has not been installed: " . $e->getTraceAsString());
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
     return self::$instance;
     #-------------------------------------------------------------------------------
 }
Ejemplo n.º 3
0
 /**
  * display debug information
  */
 public function printDebug()
 {
     $dispatcher = $this->getDI()->get('dispatcher');
     $controller = $dispatcher->getControllerName();
     $action = $dispatcher->getActionName();
     //$main = $this->getDI()->get('view')->getMainView();
     //$ = $view->getLayout(); $view->getMainView();
     $now = microtime(TRUE);
     $time = $now - $_SERVER['REQUEST_TIME'];
     echo "<style>\n\t\t.debug-table td, .debug-table th {\n\t\t\tfont-size: 10px;\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\t\t</style>\n\t\t<h7>Phalcon</h7>\n\t\t<table class='debug-table table table-striped table-condensed'>\n\t\t\t<tr>\n\t\t\t\t<td>Time</td>\n\t\t\t\t<td>{$time}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Controller</td>\n\t\t\t\t<td>{$controller}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Action</td>\n\t\t\t\t<td>{$action}</td>\n\t\t\t</tr>";
     foreach ($this->_views as $view) {
         echo "<tr><td>View</td><td>{$view}</td></tr>";
     }
     echo "</table>";
     //	Print out Session Data
     if (!empty($_SESSION)) {
         echo "<h7>Session</h7>\n\t\t\t<table class='debug-table table table-striped table-condensed'><tr><th>Session Name</th><th>Session Value</th></tr>";
         echo "<tr><td>" . session_name() . "</td><td>" . session_id() . "</td></tr>";
         foreach ($_SESSION as $index => $value) {
             echo "<tr><td>{$index}</td><td>" . printValue($value) . "</td></tr>";
         }
         echo "</table>";
     }
     //printSuperGlobal($_SESSION, "Session");
     //printSuperGlobal($_POST, "Post");
     //printSuperGlobal($_COOKIE, "Cookie");
     echo 'welcome';
     /*$queries = DatabaseFactory::getQueries();
     		if (!empty($queries)) {
     			echo "<h7>Database</h7>
     			<table class='table debug-table table-striped table-condensed'><tr><th>Query</th><th>File</th><th>Line</th><th>Success</th></tr>";
     			foreach($queries as $query) {
     				echo "<tr>
     					<td>{$query->query}</td>
     					<td>{$query->file}</td>
     					<td>{$query->line}</td>
     					<td>{$query->success}</td>
     				</tr>";	
     			}
     			echo "</table>";
     		}*/
     if (class_exists('MemcachedCache', FALSE)) {
         echo "<h7>Memcached</h7>";
         $cache = MemcachedCache::singleton();
         echo "<table class='table debug-table table-striped table-condensed'>";
         foreach ($cache->getServerList() as $server) {
             echo "<tr><td>{$server['host']}</td><td>{$server['port']}</td><td></td></tr>";
         }
         echo "</table>";
     }
     /*
     			//	Get All CLI Commands
     		$commands = Command::singleton()->getCommands();
     		if (!empty($commands)) {
     			echo "<h7>Shell Comamnds</h7>
     			<table class='table debug-table table-striped table-condensed'><tr><th>Command</th><th>File</th><th>Line</th><th>Success</th></tr>";
     
     			foreach($commands as $command) {
     				$command->toRow();
     			}
     			echo "</table>";
     		}*/
 }