本文整理汇总了PHP中CCache::init方法的典型用法代码示例。如果您正苦于以下问题:PHP CCache::init方法的具体用法?PHP CCache::init怎么用?PHP CCache::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCache
的用法示例。
在下文中一共展示了CCache::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCacheProxy
/**
* @return CCache
*/
protected function getCacheProxy()
{
if (is_null($this->_cacheProxy)) {
$this->_cacheProxy = Yii::createComponent($this->cache);
$this->_cacheProxy->init();
}
return $this->_cacheProxy;
}
示例2: init
/**
* 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.'));
}
}
示例3: init
/**
* 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.'));
}
}
示例4: init
/**
* 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.'));
}
}
示例5: init
/**
* 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"
}
}
示例6: init
/**
* 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)));
}
}
示例7: init
/**
* 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"
}
示例8: init
/**
* 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();
}
示例9: init
/**
* 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.'));
}
}
示例10: init
/**
* 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);
}
}
示例11: init
/**
* 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);
}
}
示例12: init
/**
* 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);
}
}
}
示例13: init
/**
* 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);
}
}
示例14: init
/**
* 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)));
}
}
}
示例15: init
/**
* 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());
}
}
}
}