Ejemplo n.º 1
0
 /**
  * Konstruktor
  * @param string $language
  * @param string $file
  */
 public function __construct($language, $file = 'translations.php')
 {
     $this->language = $language;
     $oCache = PhpCache::getInstance()->create();
     $oCacheKey = new CacheKey('translationList', $this->language);
     if (!self::$useCache || !$oCache->check($oCacheKey)) {
         /** @noinspection PhpIncludeInspection */
         require dirname(__FILE__) . '/../../translations/' . $file;
         /** @noinspection PhpUndefinedVariableInspection */
         $this->table = $translationTable[$this->language];
         unset($translationTable);
         if (self::$useCache) {
             $oCache->set($oCacheKey, $this->table, 86400);
         }
     } else {
         $this->table = $oCache->get($oCacheKey);
     }
 }
Ejemplo n.º 2
0
 /**
  * Template load
  *
  */
 private function load()
 {
     $key = new CacheKey('Templater::load', md5(realpath('') . '|' . $this->fileName));
     $cache = PhpCache::getInstance()->create();
     if (!self::$useCache || !$cache->check($key)) {
         if (file_exists($this->fileName)) {
             $tFile = fopen($this->fileName, 'r');
             flock($tFile, LOCK_SH);
             $this->template = fread($tFile, filesize($this->fileName));
             flock($tFile, LOCK_UN);
             fclose($tFile);
             $cache->set($key, $this->template, 86400);
         } else {
             throw new \Exception('No file in path: "' . $this->fileName . '"');
         }
     } else {
         $this->template = $cache->get($key);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param array $aParams
  */
 public function __construct(array $aParams = null)
 {
     $this->aParams = $aParams;
     $this->db = Factory::getInstance();
     $this->cache = PhpCache::getInstance()->create();
 }
Ejemplo n.º 4
0
 /**
  * Force load new data from source
  * @param array $aParams
  */
 public function forceReload($aParams = null)
 {
     PhpCache::getInstance()->create()->set($this->createCacheKey($aParams), $this->loadData($this->getUrl()), $this->cacheTime);
 }