V
V
vnpp2019-04-18 08:22:51
Yii
vnpp, 2019-04-18 08:22:51

Yii2 cache not caching queries with aggregate functions?

Queries like this are not cached

$minValue = (new Query())->cache(3600)->from(...)->min(...); 

$minValue = Yii::$app->db->cache(
    function ($db)  {
        return (new Query())->from(...)->min(...); 
    },
    3600
);

The documentation is ambiguous about the restriction
https://www.yiiframework.com/doc/guide/2.0/en/cach...
Query caching does not work with query results that contain resource handlers. For example, when using the BLOB column type in some DBMS, the query result will return a resource handler for the column data.
The size restrictions do not explicitly apply in this case.

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