From eed29a1557bf2054360bc9de341e21b1d66c09df Mon Sep 17 00:00:00 2001 From: madmatt Date: Tue, 12 Nov 2013 16:05:16 +1300 Subject: [PATCH 1/2] Update partial-caching doc to include note on using .Max and .Count together. --- docs/en/reference/partial-caching.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/en/reference/partial-caching.md b/docs/en/reference/partial-caching.md index 6d7435342..fc0018b91 100644 --- a/docs/en/reference/partial-caching.md +++ b/docs/en/reference/partial-caching.md @@ -61,13 +61,16 @@ For example, if we have a menu, we want that menu to update whenever _any_ page otherwise. By using aggregates, we can do that like this: :::ss - <% cached 'navigation', List(SiteTree).max(LastEdited) %> + <% cached 'navigation', List(SiteTree).max(LastEdited), List(SiteTree).Count() %> If we have a block that shows a list of categories, we can make sure the cache updates every time a category is added or edited :::ss - <% cached 'categorylist', List(Category).max(LastEdited) %> + <% cached 'categorylist', List(Category).max(LastEdited), List(Category).Count() %> + +Note the use of both .max(LastEdited) and .Count() - this takes care of both the case where an object has been edited +since the cache was last built, and also when an object has been deleted/un-linked since the cache was last built. We can also calculate aggregates on relationships. A block that shows the current member's favourites needs to update whenever the relationship Member::$has_many = array('Favourites' => Favourite') changes. From f0ae1160edcb5fd926fe4acf7fca7459cbb63b8d Mon Sep 17 00:00:00 2001 From: madmatt Date: Tue, 12 Nov 2013 17:22:59 +1300 Subject: [PATCH 2/2] Update partial-caching.md --- docs/en/reference/partial-caching.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/reference/partial-caching.md b/docs/en/reference/partial-caching.md index fc0018b91..5bf957596 100644 --- a/docs/en/reference/partial-caching.md +++ b/docs/en/reference/partial-caching.md @@ -61,15 +61,15 @@ For example, if we have a menu, we want that menu to update whenever _any_ page otherwise. By using aggregates, we can do that like this: :::ss - <% cached 'navigation', List(SiteTree).max(LastEdited), List(SiteTree).Count() %> + <% cached 'navigation', List(SiteTree).max(LastEdited), List(SiteTree).count() %> If we have a block that shows a list of categories, we can make sure the cache updates every time a category is added or edited :::ss - <% cached 'categorylist', List(Category).max(LastEdited), List(Category).Count() %> + <% cached 'categorylist', List(Category).max(LastEdited), List(Category).count() %> -Note the use of both .max(LastEdited) and .Count() - this takes care of both the case where an object has been edited +Note the use of both .max(LastEdited) and .count() - this takes care of both the case where an object has been edited since the cache was last built, and also when an object has been deleted/un-linked since the cache was last built. We can also calculate aggregates on relationships. A block that shows the current member's favourites needs to update