A
A
akula222016-09-06 23:21:45
Yii
akula22, 2016-09-06 23:21:45

Cache not working, why?

Find out if there is a new message for the user

$newMessage = Pm::getDb()->cache(function ($db) {
            return Pm::find()->where(['status' => Pm::STATUS_UNREAD , 'user_id' => Yii::$app->user->id])->count();
        }, 60);

I receive a number of new messages. I want to cache the request for a minute, but for some reason it doesn’t work, in this option the request does not go to the database, not in a minute, not in 10

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