农夫三拳 2017-08-19 16:02:31 3396次浏览 0条评论 0 3 0
    public function beforeAction($action)
    {
        $model=Sort::find();

        $sort['user']=$model->where(["type"=>1,"user_id"=>\Yii::$app->user->id])->asArray()->all();

        $sort['company']=$model->where(["type"=>2])->asArray()->all();

        $cache=\Yii::$app->cache;

        $expression=new ExpressionDependency(['expression'=>'(new \frontend\models\Sort())::find()->asArray()->all()']);

        $cache->add('cate',$sort,3000,$expression);

        $cate=$cache->get('cate');

        if ($cate===false) {
            $cache->set('cate', $sort);
        }

        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }

这个表达式依赖缓存linux下无法正常执行,
想了想估计是万恶的权限,yii2缓存组件缓存的目录为(比如说你是backend应用):backend/runtime/cache

cd 你的项目根目录/backend/runtime

chmod -R 777 cache

这样就没有什么问题了 很简单,希望能帮助到刚入门的朋友,大神勿喷。

觉得很赞
    没有找到数据。
您需要登录后才可以评论。登录 | 立即注册