summaryrefslogtreecommitdiffstats
path: root/lib/private/App/InfoParser.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/App/InfoParser.php')
-rw-r--r--lib/private/App/InfoParser.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/private/App/InfoParser.php b/lib/private/App/InfoParser.php
index 3c14fe7c0cf..fbeb932763e 100644
--- a/lib/private/App/InfoParser.php
+++ b/lib/private/App/InfoParser.php
@@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
*
* @author Andreas Fischer <bantu@owncloud.com>
* @author Christoph Wurst <christoph@owncloud.com>
@@ -26,7 +27,18 @@
namespace OC\App;
+use OCP\ICache;
+
class InfoParser {
+ /** @var \OCP\ICache|null */
+ private $cache;
+
+ /**
+ * @param ICache|null $cache
+ */
+ public function __construct(ICache $cache = null) {
+ $this->cache = $cache;
+ }
/**
* @param string $file the xml file to be loaded
@@ -37,6 +49,13 @@ class InfoParser {
return null;
}
+ if(!is_null($this->cache)) {
+ $fileCacheKey = $file . filemtime($file);
+ if ($cachedValue = $this->cache->get($fileCacheKey)) {
+ return json_decode($cachedValue, true);
+ }
+ }
+
libxml_use_internal_errors(true);
$loadEntities = libxml_disable_entity_loader(false);
$xml = simplexml_load_file($file);
@@ -119,6 +138,10 @@ class InfoParser {
if (isset($array['background-jobs']['job']) && is_array($array['background-jobs']['job'])) {
$array['background-jobs'] = $array['background-jobs']['job'];
}
+
+ if(!is_null($this->cache)) {
+ $this->cache->set($fileCacheKey, json_encode($array));
+ }
return $array;
}