public function init() { parent::init(); $this->_texts = Data::cache(TextModel::CACHE_KEY, 3600, function () { $models = TextModel::find()->where(['status' => TextModel::STATUS_PUBLISHED])->all(); $return = []; foreach ($models as $k => $model) { $return[$model->slug . '_' . \Yii::$app->language][$model->id] = $model; } return $return; }); }
/** * @return Country[] */ public function api_countries() { return Data::cache($this->makeCacheKey(), function () { return Country::find()->all(); }); }