Faizan Khattak
Faizan Khattak

Reputation: 882

Caching ActiveDataProvider with redis

How i cache data of active data provider query. If query run its get data from cache

return new ActiveDataProvider([
    'query' => Aircraft::find()->andWhere(['owner_id' => 6, 'owner_type' => 'organization']),
]);

Upvotes: 0

Views: 200

Answers (1)

rob006
rob006

Reputation: 22174

Using cache() should be enough (as long as you have configured cache component):

return new ActiveDataProvider([
    'query' => Aircraft::find()
        ->andWhere(['owner_id' => 6, 'owner_type' => 'organization'])
        ->cache($cacheDuration),
]);

Upvotes: 1

Related Questions