| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Settings\Storage\Backend; |
|
|
| use Piwik\Tracker; |
| use Piwik\Cache as PiwikCache; |
|
|
| |
| |
| |
| |
| |
| class Cache implements BackendInterface |
| { |
| |
| |
| |
| private $backend; |
|
|
| public function __construct(BackendInterface $backend) |
| { |
| $this->backend = $backend; |
| } |
|
|
| |
| |
| |
| public function save($values) |
| { |
| $this->backend->save($values); |
| self::clearCache(); |
| } |
|
|
| public function getStorageId() |
| { |
| return $this->backend->getStorageId(); |
| } |
|
|
| public function delete() |
| { |
| $this->backend->delete(); |
| self::clearCache(); |
| } |
|
|
| public function load() |
| { |
| $cacheId = $this->getStorageId(); |
| $cache = self::buildCache(); |
|
|
| if ($cache->contains($cacheId)) { |
| return $cache->fetch($cacheId); |
| } |
|
|
| $settings = $this->backend->load(); |
| $cache->save($cacheId, $settings); |
|
|
| return $settings; |
| } |
|
|
| public static function clearCache() |
| { |
| Tracker\Cache::deleteTrackerCache(); |
| self::buildCache()->flushAll(); |
| } |
|
|
| public static function buildCache() |
| { |
| return PiwikCache::getEagerCache(); |
| } |
| } |
|
|