To use this application component, the APC PHP extension must be loaded. Alternatively APCu PHP extension could be used via setting useApcu to true. In order to enable APC or APCu for CLI you should add "apc.enable_cli = 1" to your php.ini. See Cache for common cache operations that ApcCache supports. For more details and usage information on Cache, see the guide article on caching.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends Cache
コード例 #1
0
 /**
  * @inheritdoc
  * 
  * Creates the default cache component if it is not provided.
  */
 public function init()
 {
     parent::init();
     $this->controllerNamespace = 'jlorente\\captcha';
     $this->setAliases(['@captchaRoute' => '/' . $this->getUniqueId() . '/captcha/index']);
     if (empty($this->cache)) {
         $this->setCache(['class' => ApcCache::className(), 'keyPrefix' => 'captcha_']);
     }
     if (empty($this->captchaAction)) {
         $this->captchaAction = ['class' => CaptchaAction::className(), 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null];
     }
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: jc21/snippets-site
 /**
  * loadLanguages
  *
  * @return bool
  */
 protected function loadLanguages()
 {
     $cacheKey = Yii::$app->params['cacheKeys']['languages'];
     $languages = $this->cache->get($cacheKey);
     if (!$languages) {
         $languages = [];
         $result = Language::find()->where(['isHidden' => 0])->orderBy('name')->all();
         foreach ($result as $language) {
             if (count($language->snippets)) {
                 $languages[$language->id] = $language->attributes;
                 $languages[$language->id]['count'] = count($language->snippets);
             }
         }
         $this->cache->set($cacheKey, $languages, 600);
     }
     $this->languages = $languages;
 }
コード例 #3
0
ファイル: ApcCache.php プロジェクト: yurii-github/yii2-mylib
 public function init()
 {
     $this->useApcu = true;
     parent::init();
 }