Example #1
0
 /**
  * @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;
 }
Example #2
0
 /**
  * @param string $tableName
  *
  * @return array
  */
 public function &getColumnsMetadata($tableName)
 {
     if (!isset(self::$columnsMetadata[$tableName])) {
         self::$columnsMetadata[$tableName] = static::$useMemcacheForMetadata ? Memcache::remember(hash('md5', $tableName . '.meta'), function () use($tableName) {
             return $this->retrieveColumnsMetadata($tableName);
         }) : $this->retrieveColumnsMetadata($tableName);
     }
     return self::$columnsMetadata[$tableName];
 }
Example #3
0
$mEngine = null;
try {
    $time = microtime(true);
    $mEngine = new ApplicationEngine();
    $content = $mEngine->generateResponse();
    echo $content;
    // TODO [alek13]: bring out
    if (DEBUG && $mEngine->responseType == ResponseType::html) {
        if ($mEngine->showProfilerInfoOnDebug) {
            echo '<pre style="background-color:#333;color:lime;padding:4px;border:solid 1px lime">';
            echo '<div align=center>';
            echo 'memory usage: <b>' . memory_get_peak_usage() . '</b>';
            $time = microtime(true) - $time;
            echo '<div style=/*font-size:' . (10 + round($time * 10)) . 'px>Время генерации страницы: <b>' . $time . '</b></div>';
            echo 'количество запросов: <b>' . MySQL::$queriesCount . '</b><br>';
            echo 'количество запросов к Memcache: <b>' . Memcache::getQueriesCount() . '</b><br>';
            echo '</div>';
            echo MySQL::$strQueries;
            echo '</pre>';
        }
        if ($mEngine->showAppDevToolsOnDebug) {
            echo '<div style="position:absolute;top:0px;right:0px;border:solid 1px #678;margin:4px;padding:4px 6px;background-color:#def;opacity:0.6;z-index:10000">';
            echo '<a href=/devtools/sess_destroy>session destroy</a> | ';
            echo '<a href=/devtools/unset_session>unset session</a> | ';
            echo '<a href=/devtools/show_session>show session</a>';
            echo '</div>';
        }
    }
} catch (BuisnessLogicException $exc) {
    $message = "\n" . 'error [' . $exc->getCode() . ']: ' . $exc->getMessage();
    if ($mEngine->responseType == ResponseType::rpc) {
Example #4
0
 public static function getModuleViewCached($division, $module, $method)
 {
     $params = func_get_args();
     if (Config::application('useCache') && !DEBUG) {
         $key = self::getCacheKeyForCall($params);
         $retValue = Memcache::remember($key, function () use($params) {
             return call_user_func_array(array('self', 'getModuleView'), $params);
         });
     } else {
         // [TODO]: cache 2 file
         //call_user_func_array(array(self,'getModuleView'),$params);
         $retValue = call_user_func_array(array('self', 'getModuleView'), $params);
     }
     return $retValue;
 }