public static function get_cache($conf) { if (empty(self::$cache)) { $frontCache = new \Phalcon\Cache\Frontend\None(array("lifetime" => $conf->lifetime)); $cache = new \Rpp\Extend\Memcache($frontCache, array("host" => $conf->host, "port" => $conf->port, "prefix" => $conf->prefix, "statsKey" => $conf->stats)); $cache->localconnect(); return self::$cache = $cache; } else { return self::$cache; } }
private function init_cache($options = array()) { $this->_di->set('cache', function () { $frontCache = new Phalcon\Cache\Frontend\Data(array("lifetime" => $this->_conf->cache->lifetime)); $cache = false; $cache = new Rpp\Extend\Memcache($frontCache, array("host" => $this->_conf->cache->memcache->host, "port" => $this->_conf->cache->memcache->port, "prefix" => $this->_conf->cache->memcache->prefix, "statsKey" => $this->_conf->cache->memcache->stats)); $cache->localconnect(); return $cache; }); }
$loader = new \Phalcon\Loader(); $loader->registerNamespaces(array('PhpAmqpLib' => ROOTFULLPATH . '/vendor/videlalvaro/php-amqplib/PhpAmqpLib', 'Rpp\\Services' => APPFULLPATH . '/Rpp/Services/', 'Shared' => APPFULLPATH . '/Rpp/Services/Shared/Publish/', 'Rpp\\Extend' => APPFULLPATH . '/Rpp/Extend/', 'Rpp\\Analytics' => APPFULLPATH . '/Rpp/Analytics/', 'Rpp\\Destacados' => APPFULLPATH . '/Rpp/Destacados/', 'Rpp\\Repositorio' => APPFULLPATH . '/Rpp/Repositorio/', 'Rpp\\Dominio' => APPFULLPATH . '/Rpp/Dominio/')); $loader->registerDirs(array(ROOTFULLPATH . DIRS . 'app/tasks')); $loader->register(); $di->set('collectionManager', function () { return new Phalcon\Mvc\Collection\Manager(); }, true); $di->set('mongo', function () use($conf) { $mongo = new MongoClient("mongodb://" . $conf->mongo->credentials . $conf->mongo->host . ":" . $conf->mongo->port . "/" . $conf->mongo->db); return $mongo->selectDB($conf->mongo->db); }, true); $di->set('cache', function () use($conf) { $frontCache = new \Phalcon\Cache\Frontend\Data(array("lifetime" => $conf->cache->lifetime)); $cache = false; $cache = new \Rpp\Extend\Memcache($frontCache, array("host" => $conf->cache->memcache->host, "port" => $conf->cache->memcache->port, "prefix" => $conf->cache->memcache->prefix, "statsKey" => $conf->cache->memcache->stats)); $cache->localconnect(); return $cache; }); $view = new \Phalcon\Mvc\View(); $view->setViewsDir(APPFULLPATH . $conf->phalcon->viewsDir); $view->registerEngines(array($conf->volt->extn => function ($view, $di) { $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di); $compiler = $volt->getCompiler(); $compiler->addFunction('getNode', '\\Rpp\\Services\\Get\\Content::node'); $compiler->addFunction('getPart', '\\Rpp\\Services\\Get\\Content::part'); $compiler->addFunction('nUrl', '\\Rpp\\Services\\Get\\Content::nurl'); $compiler->addFunction('TrackUrl', '\\Rpp\\Services\\Get\\UrlTrack::add_params'); $compiler->addFunction('TrackUrlSocial', '\\Rpp\\Services\\Get\\UrlTrack::add_params_social'); $compiler->addFunction('cdn_image', '\\Rpp\\Services\\Get\\UrlMedia::image'); $compiler->addFunction('df_match', '\\Rpp\\Services\\Get\\Resultados::match'); $compiler->addFunction('df_campeonato', '\\Rpp\\Services\\Get\\Resultados::campeonato');