/**
  * Handle GET request
  *
  * @throws \Exception
  */
 function GET()
 {
     $key = static::EXTENSION . '_' . $this->name . '_' . $this->version;
     $files = $this->getFiles();
     $this->sendHeaders($files);
     $cache = PooledCache::Get(get_called_class(), 'Memory');
     $ret = $cache->get($key);
     if (!$ret || !\Radical\Core\Server::isProduction()) {
         $data = array();
         foreach ($files as $f) {
             if (is_file($f)) {
                 //Ignore folders
                 $fn = basename($f);
                 $data[$fn] = Individual::get_file($f);
             }
         }
         $ret = '';
         foreach ($data as $f => $d) {
             if (!\Radical\Core\Server::isProduction()) {
                 $ret .= "\r\n/* Including: " . $f . " */\r\n";
             }
             $ret .= $d;
         }
         if (\Radical\Core\Server::isProduction()) {
             $ret = $this->optimize($ret);
             $cache->set($key, $ret);
         }
     }
     echo $ret;
     $headers = \Radical\Web\Page\Handler::top()->headers;
     $headers->setContentLength(strlen($ret));
     $headers['Vary'] = 'Accept-Encoding';
 }
Example #2
0
 function execute(array $arguments)
 {
     if (!isset($_SERVER['REQUEST_URI'])) {
         $this->_Execute($arguments);
     } else {
         $key = '__cron__' . $this->getName();
         //because pool isnt working for file
         $fileCache = PooledCache::Get('cron', 'FileCache');
         $lastExecute = (int) $fileCache->Get($key);
         $lastWantTo = time() - $this->getTime();
         if (!$lastExecute || $lastExecute < $lastWantTo) {
             $this->_Execute($arguments);
             $fileCache->Set($key, time());
             return true;
         } else {
             return false;
         }
     }
 }
Example #3
0
 static function init()
 {
     self::$pool = \Radical\Cache\PooledCache::get('radical_orm', 'Memory');
     global $_SQL;
     $cfile = '/tmp/' . $_SQL->getDb();
     if (file_exists($cfile) && filemtime($cfile) >= time() - 30) {
         self::$key = file_get_contents($cfile);
     } else {
         touch($cfile);
         $sql = 'SELECT MAX(UNIX_TIMESTAMP( CREATE_TIME )) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "' . $_SQL->getDb() . '"';
         self::$key = \Radical\DB::Q($sql)->Fetch(Fetch::FIRST);
         file_put_contents($cfile, self::$key);
     }
     if (Server::isProduction()) {
         self::$data = self::$pool->get($_SQL->getDb() . '_' . self::$key);
         register_shutdown_function(function () {
             Cache::save();
         });
     }
     if (!is_array(self::$data)) {
         self::$data = array();
     }
 }