V
V
vostotskiy2017-04-20 17:38:04
MySQL
vostotskiy, 2017-04-20 17:38:04

How to pass parameter to cached request callback in Yii2?

Hello. I want to cache a request with a parameter ($ id), I
use the following construction

return self::getDb()->cache(function ($db) {
            $this->getSomeTable()
                ->filterWhere(['some_field' => $id])
                ->count();
            }, $cacheTimeout);

does not see the passed $id value.
I did not understand the documentation, did not find examples and solutions.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question