Yii2 ActiveRecord cache

后端 未结 3 1263
春和景丽
春和景丽 2020-12-17 03:03

How to use ActiveRecotd cache for Yii 2? I did\'t find any examples in official docs. In Google I found 2 examples, first is:

$db = self::getDb();
$object =          


        
3条回答
  •  我在风中等你
    2020-12-17 03:40

    Since 2.0.14 you can use the following shortcuts:

    (new Query())->cache(7200)->all();
    // and
    User::find()->cache(7200)->all();
    

    Source: https://www.yiiframework.com/doc/guide/2.0/en/caching-data

提交回复
热议问题