mirror of
https://github.com/silverstripe/silverstripe-versionfeed
synced 2024-10-22 11:05:31 +02:00
241f0604b0
Changed default settings (disable lock_bypage and set lock_timeout to 5) Updated docs
25 lines
487 B
PHP
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;
|
|
}
|
|
}
|