silverstripe-versionfeed/code/caching/CachedContentFilter.php
Damian Mooyman 241f0604b0 Namespaced filters
Changed default settings (disable lock_bypage and set lock_timeout to 5)
Updated docs
2014-04-30 12:31:18 +12:00

25 lines
487 B
PHP

<?php
namespace VersionFeed\Filters;
/**
* Caches results of a callback
*/
class CachedContentFilter extends ContentFilter {
public function getContent($key, $callback) {
$cache = $this->getCache();
// Return cached value if available
$result = isset($_GET['flush'])
? null
: $cache->load($key);
if($result) return $result;
// Fallback to generate result
$result = parent::getContent($key, $callback);
$cache->save($result, $key);
return $result;
}
}