This page [url=http://doc.silverstripe.org/partial-caching?s[]=partial&s[]=caching]http://doc.silverstripe.org/partial-caching?s[]=partial&s[]=caching does a great job at trying to explain this concept. I am looking for some more concrete example, especially as it woudl relate to a method called in a Page Class and used in a control block.
I would appreciate anyone taking a stab a dumbing this down for me, on more level. :-)
Some Sample Code:
Let's say we have a method in the Page Class that is getting the latest blog posts...
function LatestBlogPosts($num=5) {
$blogs = DataObject::get_one("BlogHolder");
return ($blogs) ? DataObject::get("BlogEntry", "ParentID = $blogs->ID", "Date DESC", "", $num) : false;
}
and then without any caching I would call this in a page template like so...
<% if LatestBlogPosts %>
<ul>
<% control LatestBlogPosts %>
<li><a href="$Link" title="Read more on "{$Title}"">$Title</a></li>
<% end_control %>
</ul>
<% end_if %>
Can someone tell me what the cache call would be for this to check if there was an updated post and then get the new result if there was.
is this even close?
<% cached 'LatestBlogPosts', Aggregate(BlogEntry).Max(LastEdited) %>
Thanks in advance. I think this feature looks awesome. Another hidden gem in SIlverstripe.
- Ed