/** * Gets the language from memcache or inserts it * @param array $tag * @return array */ public function getLanguage($tag, $fallback = false) { if ($tag == '') { return false; } $language = $this->memCache->get($this->getCacheKey($tag)); if (!$language) { $query = $this->repository->getLanguageByTag($tag); $query->execute(); $language = $query->fetch(); if ($language) { $this->memCache->set($this->getCacheKey($tag), $language); } elseif (!$fallback) { $insert = $this->repository->insertLanguageFromTag($tag); $insert->execute(); $language = $this->getLanguage($tag, true); } } return $language; }
/** * Gets the country from memcache or inserts it * @param array $tag * @return array */ public function getCountry($tag, $fallback = false) { if ($tag == '') { return false; } $country = $this->memCache->get($this->getCacheKey($tag)); if (!$country) { $query = $this->repository->getCountryByAlpha($tag); $query->execute(); $country = $query->fetch(); if ($country) { $this->memCache->set($this->getCacheKey($tag), $country); } elseif (!$fallback) { $insert = $this->repository->insertCountryFromAlpha($tag); $insert->execute(); $country = $this->getCountry($tag, true); } } return $country; }
public function set($key, $data, $expiration = self::DEFAULT_EXPIRATION, $compress = null) { return parent::set($key, $data, $expiration, $compress); }