本文整理汇总了PHP中app\models\Post::commonTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::commonTag方法的具体用法?PHP Post::commonTag怎么用?PHP Post::commonTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Post
的用法示例。
在下文中一共展示了Post::commonTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Action that displays posts list
* @return string
*/
public function actionIndex()
{
$languageId = Yii::$app->multilingual->language_id;
$posts = Post::find()->orderBy(['created_at' => SORT_DESC]);
$count = Yii::$app->cache->lazy(function () use($posts) {
return $posts->count();
}, "PostsCount:{$languageId}", 86400, Post::commonTag());
$pagination = new Pagination(['totalCount' => $count]);
$posts = Yii::$app->cache->lazy(function () use($posts, $pagination) {
return $posts->offset($pagination->offset)->limit($pagination->limit)->all();
}, "Posts:{$pagination->offset}:{$pagination->limit}:{$languageId}", 86400, Post::commonTag());
return $this->render('index', ['posts' => $posts, 'pagination' => $pagination]);
}
示例2: invalidateTags
/**
* Invalidate model tags.
* @return bool
*/
public function invalidateTags()
{
/** @var \DevGroup\TagDependencyHelper\TagDependencyTrait $this */
\yii\caching\TagDependency::invalidate($this->getTagDependencyCacheComponent(), [static::commonTag(), Post::commonTag(), $this->objectTag(), NamingHelper::getObjectTag(Post::className(), $this->getPrimaryKey())]);
return true;
}