/**
  * @return CCache
  */
 protected function getCacheProxy()
 {
     if (is_null($this->_cacheProxy)) {
         $this->_cacheProxy = Yii::createComponent($this->cache);
         $this->_cacheProxy->init();
     }
     return $this->_cacheProxy;
 }
 /**
  * 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.'));
     }
 }
Beispiel #3
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.'));
     }
 }
 /**
  * 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.'));
     }
 }
Beispiel #5
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"
     }
 }
Beispiel #6
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)));
     }
 }
Beispiel #7
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"
 }
Beispiel #8
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();
 }
Beispiel #9
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.'));
     }
 }
Beispiel #10
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);
     }
 }
 /**
  * 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);
     }
 }
 /**
  * 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);
         }
     }
 }
Beispiel #13
0
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It creates the memcache instance and adds memcache servers.
  * @throws CException if memcache extension is not loaded
  */
 public function init()
 {
     parent::init();
     $servers = $this->getServers();
     $cache = $this->getMemCache();
     if (count($servers)) {
         foreach ($servers as $server) {
             if ($this->useMemcached) {
                 $cache->addServer($server->host, $server->port, $server->weight);
             } else {
                 $cache->addServer($server->host, $server->port, $server->persistent, $server->weight, $server->timeout, $server->status);
             }
         }
     } else {
         $cache->addServer('localhost', 11211);
     }
 }
Beispiel #14
0
 /**
  * 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);
     $sql = "DELETE FROM {$this->cacheTableName} WHERE expire>0 AND expire<" . time();
     try {
         $db->createCommand($sql)->execute();
     } catch (Exception $e) {
         // The cache table does not exist
         if ($this->autoCreateCacheTable) {
             $this->createCacheTable($db, $this->cacheTableName);
         } else {
             throw new CException(Yii::t('yii', 'Cache table "{tableName}" does not exist.', array('{tableName}' => $this->cacheTableName)));
         }
     }
 }
 /**
  * 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) {
             try {
                 $this->createCacheTable($db, $this->cacheTableName);
             } catch (Exception $eInner) {
                 throw new CDbException('Cache purge failed: ' . $e->getMessage() . "\n\nAdditionally the following error was encountered while trying to prepare the cache: " . $eInner->getMessage());
             }
         }
     }
 }
Beispiel #16
0
 public function init($config)
 {
     if (!empty($config["server"])) {
         try {
             $this->obj = new Redis();
             if ($config["pconnect"]) {
                 $connect = @$this->obj->pconnect($config["server"], $config["port"]);
             } else {
                 $connect = @$this->obj->connect($config["server"], $config["port"]);
             }
         } catch (RedisException $e) {
         }
         $this->enable = $connect ? true : false;
         if ($this->enable) {
             @$this->obj->setOption(Redis::OPT_SERIALIZER, $config["serializer"]);
         }
     }
     parent::init();
 }
Beispiel #17
0
 /**
  * Here we connect the Iron Cache to prepare for setting, getting or deleting cache entries.
  */
 public function init()
 {
     parent::init();
     $this->_yiiron = Yii::app()->yiiron;
 }
Beispiel #18
0
 /**
  * Establishes a connection to the redis server.
  * It does nothing if the connection has already been established.
  * @throws CException if connecting fails
  */
 public function init()
 {
     parent::init();
     $this->connect();
 }
Beispiel #19
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();
 }
Beispiel #20
0
 public function init()
 {
     parent::init();
     $servers = $this->getServers();
     $cache = $this->getMemCache();
 }
 /**
  * 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();
     $this->getRedis();
 }
Beispiel #22
-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.'));
     }
 }