I
I
Ilya Beloborodov2015-12-10 11:13:22
Yii
Ilya Beloborodov, 2015-12-10 11:13:22

Explain how query caching works in Yii?

Here is a piece from the documentation

$dependency = new CDbCacheDependency('SELECT MAX(update_time) FROM tbl_post');
$posts = Post::model()->cache(1000, $dependency)->findAll();
// реляционный запрос
$posts = Post::model()->cache(1000, $dependency)->with('author')->findAll();

In the first line, we check if any article has changed? And if MAX(update_time) hasn't changed since the last check, then the query result is retrieved from the cache? And if MAX(update_time) has been changed, is MAX(update_time) cached along with the query result? Did I understand correctly?
And 1000 is the cache id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Beloborodov, 2015-12-10
@kowap

He answered off the forum
I understood everything correctly.
1000 is the cache lifetime

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question