Unable to cache Mongodb Active Record

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??

May be you could use smth like this?

self::find()->cache(function ($db, $userId) { ... });

I didn’t try to execute such code, but \yii\db\Query has the cache(…) method, using it seems a solution to me