Example #1
0
 /**
  * Teardown environment
  *
  * @return void
  */
 protected function tearDown()
 {
     $cache = new CCache();
     $cache->setDir(CACHE_PATH);
     $this->removeFilesInCacheDir();
     $cache->removeSubdir(self::DUMMY);
 }
  private function loadPageXml($xmlFile)
  {
    /* init */
    $file   = CONTROLLER_PATH . $xmlFile;
    $this->m_fileName = $xmlFile;
    $cCache = new CCache($this->m_cConfig, $file);
    $retXml = array();

    /**
     * Can it use cache? */
    if ($cCache->useCache() == true) {
      $retXml   = $cCache->getCache();
    }
    /**
     * Read the xml file and cache it */
    else {
      $xmlData  = new CXmlController($file);
      $xmlData->setDefaultType("string-iso");

      $xmlData->startParser();
      $retXml   = $xmlData->getXmlData();

      /* cache */
      $cCache->setCache($retXml);
    }

    return $retXml;
  }
  public  function loadUrl()
  {
    /* init cache object */
    $cCache = new CCache($this->m_cConfig, $this->m_xmlFile); 

    /* if it can use the cache, I use it or I cache it! */
    if ($cCache->useCache == true) {
      $urlX   = $cCache->getCache();
    }
    /**
     * Cache config */
    else {
      $xmlData = new CXmlController($this->m_xmlFile);
      $xmlData->setDefaultType("string-utf8");

      $xmlData->startParser();
      $urlX    = $xmlData->getXmlData();

      /* cache it for next one */
      $cCache->setCache($urlX);
    }

    /* erstelle m_urlXml */
    $this->assocUrl($urlX);
  }
 /**
  * @return CCache
  */
 protected function getCacheProxy()
 {
     if (is_null($this->_cacheProxy)) {
         $this->_cacheProxy = Yii::createComponent($this->cache);
         $this->_cacheProxy->init();
     }
     return $this->_cacheProxy;
 }
Example #5
0
 protected function render($view, $controller = "site", $arrResult = array(), $template = TEMPLATE)
 {
     $cache = new CCache(604800);
     $flagCache = false;
     if (!$cache->cacheExists(CApp::getHashCurPage()) && false) {
         $flagCache = true;
         $cache->startCache();
     }
     include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/header.php";
     include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/views/" . strtolower($controller) . "/" . $view . ".php";
     include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/footer.php";
     if ($flagCache) {
         $cache->writeCache(filterGetValue(CApp::getHashCurPage()));
     }
 }
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It checks the availability of eAccelerator.
  * @throws CException if eAccelerator extension is not loaded, is disabled or the cache functions are not compiled in.
  */
 public function init()
 {
     parent::init();
     if (!function_exists('eaccelerator_get')) {
         throw new CException(Yii::t('yii', 'CEAcceleratorCache requires PHP eAccelerator extension to be loaded, enabled or compiled with the "--with-eaccelerator-shared-memory" option.'));
     }
 }
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It checks the availability of memcache.
  * @throws CException if memcache extension is not loaded or is disabled.
  */
 public function init()
 {
     parent::init();
     if (!function_exists('xcache_isset')) {
         throw new CException(Yii::t('yii', 'CXCache requires PHP XCache extension to be loaded.'));
     }
 }
Example #8
0
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It checks the availability of APC.
  * @throws CException if APC cache extension is not loaded or is disabled.
  */
 public function init()
 {
     parent::init();
     if (!extension_loaded('apc')) {
         throw new CException(Yii::t('yii', 'CApcCache requires PHP apc extension to be loaded.'));
     }
 }
Example #9
0
 /**
  * Initializes this application component.
  * ensureIndex 'key' if $ensureIndex = true
  * Set $ensureIndex to false after first use to increase performance
  *
  * This method is required by the {@link IApplicationComponent} interface.
  * It ensures the existence of the cache DB table.
  * It also removes expired data items from the cache.
  */
 public function init()
 {
     parent::init();
     if ($this->ensureIndex) {
         $this->getCollection()->createIndex(['key' => 1]);
         // create index on "key"
     }
 }
Example #10
0
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It checks the availability of APC.
  * @throws CException if APC cache extension is not loaded or is disabled.
  */
 public function init()
 {
     parent::init();
     $extension = $this->useApcu ? 'apcu' : 'apc';
     if (!extension_loaded($extension)) {
         throw new CException(Yii::t('yii', "CApcCache requires PHP {extension} extension to be loaded.", array('{extension}' => $extension)));
     }
 }
Example #11
0
 public function __construct(&$db)
 {
     parent::__construct('#__community_config', 'name', $db);
     // Get cache object.
     $oCache = CCache::inject($this);
     // Remove all cache on configuration change.
     $oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, COMMUNITY_CACHE_TAG_ALL);
 }
Example #12
0
 /**
  *	Delete cahche on request.
  **/
 function deleteCache($method)
 {
     if ($oCache = CCache::load($this)) {
         if ($aSetting = $oCache->getMethod($method)) {
             $oCache->remove($aSetting['tag']);
         }
     }
 }
Example #13
0
 /**
  * Constructor
  */
 function CTableVideosCategory(&$db)
 {
     parent::__construct('#__community_videos_category', 'id', $db);
     // Get cache object.
     $oCache = CCache::inject($this);
     // Remove video cache on every delete & store
     $oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_VIDEOS_CAT));
     $oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_VIDEOS_CAT));
 }
Example #14
0
 protected function render($view, $controller = "site", $arrResult = [], $template = null)
 {
     if ($template == null) {
         $template = CApp::settings('APPLICATION')->templates['default'];
     }
     $cache = new CCache(604800);
     $flagCache = false;
     if (!$cache->cacheExists(CApp::getHashCurPage()) && CApp::settings("APPLICATION")->settings['cache_on']) {
         $flagCache = true;
         $cache->startCache();
     }
     include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/header.php";
     include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/views/" . strtolower($controller) . "/" . $view . ".php";
     include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/footer.php";
     if ($flagCache) {
         $cache->writeCache(filterGetValue(CApp::getHashCurPage()));
     }
 }
Example #15
0
 /**
  * Initializes this application component.
  * ensureIndex 'key' if $ensureIndex = true
  * Set $ensureIndex to false after first use to increase performance
  *
  * This method is required by the {@link IApplicationComponent} interface.
  * It ensures the existence of the cache DB table.
  * It also removes expired data items from the cache.
  */
 public function init()
 {
     parent::init();
     $collection = $this->getCollection();
     if ($this->ensureIndex) {
         $collection->ensureIndex(array('key' => 1));
     }
     // create index on "key"
 }
Example #16
0
 /**
  * Constructor
  */
 public function __construct(&$db)
 {
     parent::__construct('#__community_events', 'id', $db);
     // Get cache object.
     $oCache = CCache::inject($this);
     // Remove video cache on every delete & store
     $oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_EVENTS_CAT));
     $oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_EVENTS_CAT));
 }
Example #17
0
 /**
  * Constructor
  */
 public function __construct(&$db)
 {
     parent::__construct('#__community_groups_category', 'id', $db);
     // Get cache object.
     $oCache = CCache::inject($this);
     // Remove groups category cache on every delete & store
     $oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_GROUPS_CAT));
     $oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_GROUPS_CAT));
 }
Example #18
0
 /**
  * Constructor
  */
 function __construct(&$db)
 {
     parent::__construct('#__community_photos_albums', 'id', $db);
     // Get cache object.
     $oCache = CCache::inject($this);
     // Remove photo cache on album delete.
     $oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_PHOTOS));
     $oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_ALBUMS));
 }
  public function loadConfig($xmlFile)
  {
    $xmlFile  = $this->m_path + $xmlFile;

    /* init cache object for config file */
    $cCache = new CCache($this->m_cConf, $xmlFile); 

    /* if I can use the cache, I use it or I cache it! */
    if ($cCache->useCache == true) {
      $this->m_config = $cCache->getCache();
    }
    /**
     * Cache config */
    else {
      parent::loadConfig($xmlFile); 
      $cCache->setCache($this->m_config);
    }
  }
Example #20
0
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It creates the redis instance and adds redis servers.
  * @throws CException if redis extension is not loaded
  */
 public function init()
 {
     parent::init();
     $servers = $this->getServers();
     if (!count($servers)) {
         $this->_servers[] = $servers = array('host' => '127.0.0.1', 'port' => 6379);
     }
     $this->getRedis();
 }
Example #21
0
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It checks the availability of WinCache extension and WinCache user cache.
  * @throws CException if WinCache extension is not loaded or user cache is disabled
  */
 public function init()
 {
     parent::init();
     if (!extension_loaded('wincache')) {
         throw new CException(Yii::t('yii', 'CWinCache requires PHP wincache extension to be loaded.'));
     }
     if (!ini_get('wincache.ucenabled')) {
         throw new CException(Yii::t('yii', 'CWinCache user cache is disabled. Please set wincache.ucenabled to On in your php.ini.'));
     }
 }
Example #22
0
 function __construct()
 {
     // Get cache object.
     $oCache = CCache::inject($this);
     $oCache->addMethod('add', CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     $oCache->addMethod('removeOneActivity', CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     $oCache->addMethod('removeActivity', CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     $oCache->addMethod('deleteActivity', CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     parent::__construct();
 }
Example #23
0
 public function __construct($lifeTime)
 {
     self::$cacheDir = $_SERVER["DOCUMENT_ROOT"] . "/cache/";
     if (!is_dir(self::$cacheDir)) {
         if (mkdir(self::$cacheDir)) {
             throw new CException(__CLASS__, "Не удается создать папку для Кэша ");
         }
     }
     $this->lifeTime = $lifeTime;
 }
Example #24
0
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  */
 public function init()
 {
     parent::init();
     if ($this->cachePath === null) {
         $this->cachePath = Yii::app()->getRuntimePath() . DIRECTORY_SEPARATOR . 'cache';
     }
     if (!is_dir($this->cachePath)) {
         mkdir($this->cachePath, 0777, true);
     }
 }
 /**
  * Release acquired mutex.
  * 
  * @param  string $name
  * @return bool
  */
 public function release($name)
 {
     if (!isset($this->acqiured[$name])) {
         return false;
     }
     $lockName = $this->getLockName($name);
     $this->cache->delete($lockName);
     unset($this->acqiured[$name]);
     return true;
 }
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It creates the memcacheSASL instance and adds memcache servers.
  */
 public function init()
 {
     include 'MemcacheSASL.php';
     parent::init();
     $server = $this->getServer();
     $cache = $this->getMemCache();
     if ($server) {
         $cache->addServer($server->host, $server->port);
         $cache->setSaslAuthData($server->username, $server->password);
     }
 }
Example #27
0
 /**
  * Constructor
  */
 public function __construct(&$db)
 {
     parent::__construct('#__community_events', 'id', $db);
     // Get cache object.
     $oCache = CCache::inject($this);
     // Remove video cache on every delete & store
     $oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_EVENTS_CAT));
     $oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_EVENTS_CAT));
     // Set default timezone to current user's timezone
     $my = CFactory::getUser();
     $this->offset = $my->getParam('timezone');
 }
 /**
  * Initializes this application component.
  *
  * This method is required by the {@link IApplicationComponent} interface.
  * It ensures the existence of the cache DB table.
  * It also removes expired data items from the cache.
  */
 public function init()
 {
     parent::init();
     $db = $this->getDbConnection();
     $db->setActive(true);
     if ($this->autoCreateCacheTable) {
         $sql = "DELETE FROM {$this->cacheTableName} WHERE expire>0 AND expire<" . time();
         try {
             $db->createCommand($sql)->execute();
         } catch (Exception $e) {
             $this->createCacheTable($db, $this->cacheTableName);
         }
     }
 }
Example #29
0
 /**
  * Constructor
  */
 public function CommunityModelGroups()
 {
     parent::JCCModel();
     $mainframe = JFactory::getApplication();
     // Get pagination request variables
     $limit = $mainframe->getCfg('list_limit') == 0 ? 5 : $mainframe->getCfg('list_limit');
     $limitstart = JRequest::getVar('limitstart', 0, 'REQUEST');
     // In case limit has been changed, adjust it
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
     // Get cache object.
     $oCache = CCache::inject($this);
     $oCache->addMethod('setImage', CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_GROUPS));
 }
Example #30
-1
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It checks the availability of Zend Data Cache.
  * @throws CException if Zend Data Cache extension is not loaded.
  */
 public function init()
 {
     parent::init();
     if (!function_exists('zend_shm_cache_store')) {
         throw new CException(Yii::t('yii', 'CZendDataCache requires PHP Zend Data Cache extension to be loaded.'));
     }
 }