Hey,
I like to cache DB queries in ActiveRecord contexct, using the methods explained here (Caching: Data Caching | The Definitive Guide to Yii 2.0 | Yii PHP Framework).
So I did the follwoing:
use yii\mongodb\ActiveRecord;
use yii\data\ActiveDataProvider;
[...]
class Users extends ActiveRecord
{
[...]
public function getUserSettings($userId)
{
$activeRecord = self::getDb()->cache(function ($db, $userId) {
return self::find()->where(['USER' => $userId]);
});
$dataProvider = new ActiveDataProvider([
'query' => $activeRecord,
'pagination' => [
'pageSize' => 10,
]
]);
return $dataProvider;
}
}
This results in: "Calling unknown method: yii\mongodb\Connection::cache()"
I found that issue (Calling unknown method: yii\mongodb\Connection::cache() · Issue #189 · yiisoft/yii2-mongodb · GitHub). It looks like caching mongodb is added 2020 for \yii\mongodb\Query
but probably not for yii\mongodb\ActiveRecord
??