Is it possible to store in cache results of lazy loading queries?

Let’s say I have a relationship defined in my model’s (Posts) relations called “author”, then I do this:




$posts = Posts::model()->findAll(); // I'm not using "with" here!!!!!

foreach ($posts as $post) {

   echo $post->author->name; // one query per iteration!!!

}

Obviously this will throw N queries, where N is the number of posts, in order to get each author’s name. But many posts could have the same author, so many queries could be redundant. Is there any way to store these redundant queries’s results in cache, so even if thos of queries are tried, most of them will hit the cache and not the database?

Thanks.