コード例 #1
0
 /**
  * Set environmental variables
  */
 public static function set()
 {
     ini_set('date.timezone', 'Europe/Warsaw');
     ini_set('date.default_latitude', '31.7667');
     ini_set('date.default_longitude', '35.2333');
     ini_set('date.sunrise_zenith', '90.583333');
     ini_set('date.sunset_zenith', '90.583333');
     date_default_timezone_set("Europe/Warsaw");
     mb_internal_encoding("UTF-8");
     setlocale(LC_ALL, 'en_US');
     /*
      * Set caching configuration
      */
     PhpCache::$sDefaultMechanism = Config::getInstance()->get('cacheMethod');
     Memcached::$host = Config::getInstance()->get('memcachedIP');
     Memcached::$port = Config::getInstance()->get('memcachedPort');
     Controller::setDefaultLanguage('pl');
 }
コード例 #2
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);
     }
 }
コード例 #3
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);
     }
 }
コード例 #4
0
ファイル: Base.php プロジェクト: PhanQuocTrung/WeatherStation
 /**
  * @param array $aParams
  */
 public function __construct(array $aParams = null)
 {
     $this->aParams = $aParams;
     $this->db = Factory::getInstance();
     $this->cache = PhpCache::getInstance()->create();
 }
コード例 #5
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);
 }