herroffizier/yii2-ar-tag-cache
Composer 安装命令:
composer require herroffizier/yii2-ar-tag-cache
包简介
Yii 2 component for automatic cache invalidation invoked by ActiveRecord updates.
README 文档
README
Yii2 AR Tag Cache automatically invalidates tagged cache when ActiveRecord changes.
In fact it is a simple wrapper over Yii2's TagDependency. It creates special tag for ActiveRecord class and invalidates all cache marked by that tag when any of that class instances is being created, updated or deleted.
Installation
Install extension with Composer:
composer require "herroffizier/yii2-ar-tag-cache:@stable"
Attach behavior to AR model:
public function behaviors() { return [ 'arCache' => [ 'class' => \herroffizier\yii2artc\Behavior::className(), ], ]; }
Usage
// Get tag dependency: $dependency = $model->tagDependency; // Attach dependency to cache: Yii::$app->cache->set('cache', 'test', 0, $dependency); // Now if you call save() or delete() for any instance of $model's class, cache will be invalidated. // Also you may force cache invalidation without modifying models: $model->invalidateCache();
统计信息
- 总下载量: 917
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2016-04-09