当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::className方法代码示例

本文整理汇总了PHP中yii\caching\Cache::className方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::className方法的具体用法?PHP Cache::className怎么用?PHP Cache::className使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\caching\Cache的用法示例。


在下文中一共展示了Cache::className方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (!empty($this->cache)) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
 }
开发者ID:cdcchen,项目名称:yii2-wechat,代码行数:10,代码来源:QyClient.php

示例2: beforeAction

 public function beforeAction($action)
 {
     if (!$this->enabled) {
         return true;
     }
     $this->cache = Instance::ensure($this->cache, Cache::className());
     $this->cache->cachePath = Yii::getAlias($this->cachePath) . '/' . $action->getUniqueId();
     if (is_array($this->dependency)) {
         $this->dependency = Yii::createObject($this->dependency);
     }
     $properties = [];
     foreach (['cache', 'duration', 'dependency', 'variations'] as $name) {
         $properties[$name] = $this->{$name};
     }
     $id = $this->varyByRoute ? $action->getUniqueId() : __CLASS__;
     $response = Yii::$app->getResponse();
     ob_start();
     ob_implicit_flush(false);
     if ($this->view->beginCache($id, $properties)) {
         $response->on(Response::EVENT_AFTER_SEND, [$this, 'cacheResponse']);
         return true;
     } else {
         $data = $this->cache->get($this->calculateCacheKey());
         if (is_array($data)) {
             $this->restoreResponse($response, $data);
         }
         $response->content = ob_get_clean();
         return false;
     }
 }
开发者ID:VampireMe,项目名称:admin-9939-com,代码行数:30,代码来源:PageCacheFilter.php

示例3: init

 public function init()
 {
     if (null !== $this->cache) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
     parent::init();
 }
开发者ID:hughcube,项目名称:apppush,代码行数:7,代码来源:RongCloud.php

示例4: init

 /**
  * Initialize the component
  */
 public function init()
 {
     parent::init();
     if ($this->cache !== null) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
     $this->model = new $this->modelClass();
 }
开发者ID:yii2song,项目名称:yii2-settings,代码行数:11,代码来源:Settings.php

示例5: __construct

 /**
  * Singleton construct.
  */
 protected function __construct()
 {
     try {
         $this->cache = Instance::ensure($this->cache, DefaultCache::className());
     } catch (Exception $e) {
         $this->cache = new DummyCache();
     }
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:11,代码来源:Cache.php

示例6: actionFlushCache

 public function actionFlushCache($component = 'cache')
 {
     /** @var Cache $cache */
     $cache = Instance::ensure($component, Cache::className());
     $cache->flush();
     Yii::$app->session->setFlash(Alert::TYPE_SUCCESS, Yii::t('gromver.platform', 'Cache flushed.'));
     return $this->redirect(['index']);
 }
开发者ID:ezsky,项目名称:yii2-platform-core,代码行数:8,代码来源:DefaultController.php

示例7: init

 /**
  * Initializes the DbMessageSource component.
  * This method will initialize the [[db]] property to make sure it refers to a valid DB connection.
  * Configured [[cache]] component would also be initialized.
  * @throws InvalidConfigException if [[db]] is invalid or [[cache]] is invalid.
  */
 public function init()
 {
     parent::init();
     $this->db = Instance::ensure($this->db, Connection::className());
     if ($this->enableCaching) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
 }
开发者ID:fonclub,项目名称:i18n,代码行数:14,代码来源:DbMessageSource.php

示例8: init

 /**
  * 初始化组件
  */
 public function init()
 {
     parent::init();
     if ($this->cache !== null) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     } else {
         throw new InvalidConfigException("Cache must be turned on");
     }
     self::$wechat = $this;
 }
开发者ID:Brother-Simon,项目名称:yii2-wechat-component,代码行数:13,代码来源:Wechat.php

示例9: init

 /**
  * 初始化组件,检查参数
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if ($this->cache !== null) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
     if ($this->cache !== null && !$this->cache instanceof Cache) {
         throw new InvalidConfigException("cache must be extends \\yii\\caching\\Cache");
     }
 }
开发者ID:highestgoodlikewater,项目名称:yii2-taobao-ip,代码行数:14,代码来源:IpComponent.php

示例10: init

 /**
  * Initializes the FragmentCache object.
  */
 public function init()
 {
     parent::init();
     $this->cache = $this->enabled ? Instance::ensure($this->cache, Cache::className()) : null;
     if ($this->getCachedContent() === false) {
         $this->getView()->cacheStack[] = $this;
         ob_start();
         ob_implicit_flush(false);
     }
 }
开发者ID:pathman,项目名称:yii2comm,代码行数:13,代码来源:FragmentCache.php

示例11: initCacheComponent

 /**
  * Initialization of cache component.
  * @throws InvalidConfigException if cacheComponent is incorrect.
  */
 protected function initCacheComponent()
 {
     if ($this->cacheComponent === null || is_array($this->cacheComponent)) {
         $this->cacheComponent = Yii::createObject(array_merge(['class' => FileCache::className(), 'cachePath' => rtrim($this->compiledPath, '\\/') . '/cache', 'fileMode' => $this->fileMode, 'dirMode' => $this->mkDirMode], $this->cacheComponent ?: []));
     } elseif (is_string($this->cacheComponent)) {
         $this->cacheComponent = Yii::$app->get($this->cacheComponent);
     }
     if ($this->cacheComponent !== false && !$this->cacheComponent instanceof Cache) {
         throw new InvalidConfigException('Incorrect value of ' . __CLASS__ . '::$cacheComponent param. Calculated value of this param must be an instance of ' . Cache::className() . '.');
     }
 }
开发者ID:flexibuild,项目名称:php-safe,代码行数:15,代码来源:ViewRenderer.php

示例12: init

 /**
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (empty($this->db)) {
         throw new InvalidConfigException('UserConfig::db must be set.');
     }
     $this->db = Instance::ensure($this->db, Connection::className());
     if ($this->cache !== null) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
 }
开发者ID:cdcchen,项目名称:yii-plus,代码行数:14,代码来源:UserConfig.php

示例13: init

 /**
  * Initialize
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     $this->db = Instance::ensure($this->db, Connection::className());
     $this->authManager = Instance::ensure($this->authManager, BaseManager::className());
     $this->user = Instance::ensure($this->user, User::className());
     if (empty($this->cache)) {
         $this->cache = $this->createCacheComponent();
     } else {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
 }
开发者ID:rmrevin,项目名称:yii2-rbac-command,代码行数:16,代码来源:Command.php

示例14: init

 /**
  * Initializes the application component.
  */
 public function init()
 {
     parent::init();
     $this->cache = Instance::ensure($this->cache, Cache::className());
     if ($this->clientId === null) {
         throw new InvalidConfigException('RestfulClient::clientId must be set.');
     }
     if ($this->clientSecret === null) {
         throw new InvalidConfigException('RestfulClient::clientSecret must be set.');
     }
     if ($this->baseUrl === null) {
         throw new InvalidConfigException('RestfulClient::baseUrl must be set.');
     }
 }
开发者ID:ailingsen,项目名称:betterdebt,代码行数:17,代码来源:RestfulClient.php

示例15: init

 /**
  * @throws InvalidConfigException
  */
 public function init()
 {
     if ($this->cache) {
         /** @var Cache $cache */
         $this->cache = Instance::ensure($this->cache, Cache::className());
         $cacheKey = __CLASS__;
         if (($this->_paramsInfo = $this->cache->get($cacheKey)) === false) {
             $this->_paramsInfo = $this->fetchParamsInfo();
             $this->cache->set($cacheKey, $this->_paramsInfo, $this->cacheDuration, $this->cacheDependency);
         }
     } else {
         $this->_paramsInfo = $this->fetchParamsInfo();
     }
 }
开发者ID:ezsky,项目名称:yii2-platform-core,代码行数:17,代码来源:ParamsManager.php


注:本文中的yii\caching\Cache::className方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。