/** * * @return Environment */ public function getGwEnvironment($lang) { $mongoService = $this->getContainer()->get('app.mongo'); /* @var $mongoService MongoService */ $mongoDB = $mongoService->getCacheDatabase(); $cache = new MongoCache($mongoDB); $env = new Environment($lang); $env->setCache($cache); $env->setStorage(new MongoStorage($mongoDB)); return $env; }
/** * * @param string $key * @param callable $callable * @param integer $expiration * @return array */ protected function cacheGet($key, $callable, $expiration = 900) { $cacheKey = 'statistics/' . $this->lang . '/' . $key; $cache = $this->env->getCache(); $result = $cache->get($cacheKey); if ($result) { return $result; } $result = $callable(); $cache->set($cacheKey, $result, $expiration); return $result; }
/** * * @return Environment */ public function getGwEnvironment() { if (empty($this->gwEnvironment)) { $mongoService = $this->get('app.mongo'); /* @var $mongoService MongoService */ $mongoDB = $mongoService->getCacheDatabase(); $cache = new MongoCache($mongoDB); $env = new Environment($this->getTranslator()->getLocale()); $env->setCache($cache); $env->setStorage(new MongoStorage($mongoDB)); $this->gwEnvironment = $env; } return $this->gwEnvironment; }