Partial Caching - Understanding the Concepts

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...

If you edited the blog entry at 9am your cache key would be like "blogposts-0900". If you visited that page again and you hadn't edited the page and came back to the site at 2pm then the cache key still would be blogposts-0900, that key exists in the store so it would pull from the cached version. So the function (or functions) are used to decide whether to update that block. You can pass an unlimited amount of functions to a cached control.

Your probably asking yourself "Well hang on then it still needs to do a database query for the last edited date, so the 'cache' still hits that database!!" You are correct but doing a DB::query() for a single value is a heck of a lot faster than a DataObject::get().

Thanks for the extended explanation. The 'uniquename' declaration was what a little ambiguous in the guide in the site. I would even suggest added this part of the explanation in the guide. Your simple explanation here, added that missing part that I was looking for to understand completely how the partial caching works.

I really do not understand one thing in partial caching. To what is "cached part of website" connected to? It is said in documentation that each cache block has a unique cache key. So, for example (taken from documentation):

From a block that updates every time the Page subclass it's the template for updates
<% cached 'database', LastEdited %>

Let's assume I put that into Page.ss layout template. I have several pages on my website, who use this layout template (Page.ss).
What will be cached? Every page which uses Page.ss will have the same cached content (for example, if wrap the whole template Page.ss with the "cached")? Or it will take LastEdited for every page I open in my browser and content will be different for each page?

Let's assume I put that into Page.ss layout template. I have several pages on my website, who use this layout template (Page.ss).
What will be cached? Every page which uses Page.ss will have the same cached content (for example, if wrap the whole template Page.ss with the "cached")? Or it will take LastEdited for every page I open in my browser and content will be different for each page

It will use a cache key of the last edited date for that page and if you put that on Page.ss then it will be on a per page basis. So the Last Edited date of each page. I'm 90% sure this works on a per page. Even the Aggregate functions may cache on a per page url basis but I will need to check.