Can anyone tell me if, when I collect a has_many property from within the page controller, the results get cached?
For instance: I have a 'ProjectPage' that has_many 'Projects'. If I call $this->Projects() from the Page controller multiple times, will the results after the first call come from cache? Or should I store the results myself? I'm just not sure...
I have always assumed that DataObject::get() calls get cached. I don't really have any foundation to make that call, but it would be wholey rediculous for situations like martimiz highlights to generate the same DataObjectSet twice...
However, if they aren't cached, then there is huge room for performance increase here. In fact, I'm going to be chatting with the SS development team specifically about scalability soon and will ask them :)
Calls to relationships on a model (aka components) are always cached. This means that if you use $this->Relationship() to retrieve a has/one/many relationship it will be cached. DataObject::get_one calls are also cached, but DataObject::get() calls are not.
I have had another look (+asked the guru) and no, the calls to getComponents and getManyManyComponents are not cached. The caching code is there, but the cache gets populated only for DataObjects not sitting in the database.
So the answer is: has_many and many_many are not cached (this includes $this->Relationship() call). Has_one are cached though.