From 253083bc81c837f98cfe97203075c0232e9c9bdb Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 23 Nov 2010 05:45:21 +0000 Subject: [PATCH] MINOR Documentation for Aggregate caching (from r114077) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@114078 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Aggregate.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/model/Aggregate.php b/core/model/Aggregate.php index 92092ef85..061618473 100644 --- a/core/model/Aggregate.php +++ b/core/model/Aggregate.php @@ -20,7 +20,11 @@ * examples: Min, Max, Avg * * Aggregates are often used as portions of a cacheblock key. They are therefore cached themselves, in the 'aggregate' - * cache, although the invalidation logic prefers speed over keeping valid data. + * cache, although the invalidation logic prefers speed over keeping valid data. + * The aggregate cache is cleared through {@link DataObject::flushCache()}, which in turn is called on + * {@link DataObject->write()} and other write operations. + * This means most write operations to the database will invalidate the cache correctly. + * Use {@link Aggregate::flushCache()} to manually clear. * * NOTE: The cache logic uses tags, and so a backend that supports tags is required. Currently only the File * backend (and the two-level backend with the File backend as the slow store) meets this requirement @@ -98,6 +102,7 @@ class Aggregate extends ViewableData { $query = $this->query("$func(\"$table\".\"$attribute\")"); + // Cache results of this specific SQL query until flushCache() is triggered. $cachekey = sha1($query->sql()); $cache = self::cache();