From 4d278f1695ae32ff3b9191cf44192cf4b387eade Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Fri, 30 Oct 2015 18:08:00 +1300 Subject: [PATCH] API Add cache_lifetime config BUG Fix issue in test caching Tests for 3.2 and php 5.6 --- .travis.yml | 8 ++++---- _config.php | 4 ---- changelog.md | 10 ++++++++++ code/caching/ContentFilter.php | 12 ++++++++++++ docs/en/developer.md | 4 ++++ 5 files changed, 30 insertions(+), 8 deletions(-) delete mode 100644 _config.php create mode 100644 changelog.md diff --git a/.travis.yml b/.travis.yml index 8646647..3b812ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,12 @@ env: matrix: include: - - php: 5.3 - env: DB=PGSQL CORE_RELEASE=3.1 - php: 5.4 - env: DB=MYSQL CORE_RELEASE=3.1 + env: DB=PGSQL CORE_RELEASE=3.1 - php: 5.5 - env: DB=MYSQL CORE_RELEASE=3.1 + env: DB=MYSQL CORE_RELEASE=3 + - php: 5.6 + env: DB=MYSQL CORE_RELEASE=3.2 before_script: - phpenv rehash diff --git a/_config.php b/_config.php deleted file mode 100644 index fdd4107..0000000 --- a/_config.php +++ /dev/null @@ -1,4 +0,0 @@ -nestedContentFilter = $nestedContentFilter; @@ -27,6 +35,10 @@ abstract class ContentFilter { protected function getCache() { $cache = \SS_Cache::factory('VersionFeed_Controller'); $cache->setOption('automatic_serialization', true); + + // Map 0 to null for unlimited lifetime + $lifetime = \Config::inst()->get(get_class($this), 'cache_lifetime') ?: null; + $cache->setLifetime($lifetime); return $cache; } diff --git a/docs/en/developer.md b/docs/en/developer.md index 1d9fa82..645b41b 100644 --- a/docs/en/developer.md +++ b/docs/en/developer.md @@ -60,3 +60,7 @@ Another important variable is the `RateLimitFilter.lock_timeout` config, which i This should be increased on sites which may be slow to generate page versions, whether due to lower server capacity or volume of content (number of page versions). Requests to this page after the timeout will not trigger any rate limit safeguard, so you should be sure that this is set to an appropriate level. + +You can set the `ContentFilter.cache_lifetime` config in order to control the maximum age of the cache. +This is an integer value in seconds, and defaults to 300 (five minutes). Set it to 0 or null to make this +cache unlimited. \ No newline at end of file