andyron
- andyron 2015-06-03 已签到连续签到2天,获得了10个金钱
- andyron 2015-06-02 已签到连续签到1天,获得了5个金钱
- andyron 2015-05-28 已签到连续签到3天,获得了15个金钱
- andyron 2015-05-27 已签到连续签到2天,获得了10个金钱
- andyron 2015-05-26 已签到连续签到1天,获得了5个金钱
- andyron 赞了回答
首先配置一下缓存,自己选择是用文件缓存还是数据库缓存等。
'cache' => [ 'class' => 'yii\caching\FileCache', ],
然后就可以通过
Yii::$app->cache->set()
和Yii::$app->cache->get()
设置、获取缓存内容了。
下面是一个带缓存依赖的实例://表达式依赖 $dp = new ExpressionDependency([ 'expression' => 'count(Yii::$app->authManager->getPermissionsByUser(Yii::$app->user->id))' ]); //数据库依赖(sql) $dp2 = new DbDependency([ 'sql' => 'select max(updated_at) from auth_item', ]); //链式依赖(把以上2个依赖串起来,任何一个发生变化都会使缓存失效) Yii::$app->cache->set($key, $value, 0, new ChainedDependency([ 'dependencies' => [$dp, $dp2] ]));
- andyron 2015-05-24 已签到连续签到7天,获得了20个金钱
- andyron 2015-05-23 已签到连续签到6天,获得了20个金钱