Cache & relationships

Why does if I set cache lifetime and then get related models than cache doesn't work? example:

$users = User::find([
    'cache' => ['lifetime' => 3600, 'key' => 'top-users'],
    'limit' => 100,

some view:

foreach ($users as $user) {
   "<td>", $user->name, "</td>",
   "<td>", $user->countAvatar() ? $user->avatar->src : "", "</td>",

With related model Avatar view every time loads longest (few seconds) that should be with cache.


User::find() is doing a query only over a table: SELECT * FROM Users, how the related records could be cached if they are not part of the query?


Ok, I see. Just thought that ORM has like functional for relations. Because of it makes no sense no cache User if there'll be db-request for Avatar for any single $user->avatar. Will try to do it another way, by caching results separately from built-in caching, for example.


I added a dedicated chapter to the docs deepening in this issue, hope this help you


Thanks! It become very useful in understanding of Phalcon.