diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-06 20:00:47 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-06 20:00:47 +0100 |
commit | f2088cafb8388d5be3b22920403652718c77908b (patch) | |
tree | a7ced464b2faf677f32d2e43dc0395230ab6ca28 | |
parent | 6dcf70f2442684a1e5bc4ff49152efe9f161b7b7 (diff) | |
parent | 63bd6b25db5e3d9860e12789032b42890d23c202 (diff) | |
download | nextcloud-server-f2088cafb8388d5be3b22920403652718c77908b.tar.gz nextcloud-server-f2088cafb8388d5be3b22920403652718c77908b.zip |
Merge pull request #22859 from owncloud/cache-results-in-memcache-for-is-owncloud
Cache results of testRemoteUrl
-rw-r--r-- | apps/files_sharing/lib/external/storage.php | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php index 41f7bef589b..87f5a3598fb 100644 --- a/apps/files_sharing/lib/external/storage.php +++ b/apps/files_sharing/lib/external/storage.php @@ -55,6 +55,11 @@ class Storage extends DAV implements ISharedStorage { private $token; /** + * @var \OCP\ICacheFactory + */ + private $memcacheFactory; + + /** * @var \OCP\ICertificateManager */ private $certificateManager; @@ -67,8 +72,9 @@ class Storage extends DAV implements ISharedStorage { private $manager; public function __construct($options) { + $this->memcacheFactory = \OC::$server->getMemCacheFactory(); $discoveryManager = new DiscoveryManager( - \OC::$server->getMemCacheFactory(), + $this->memcacheFactory, \OC::$server->getHTTPClientService() ); @@ -241,10 +247,21 @@ class Storage extends DAV implements ISharedStorage { } } + /** + * @param string $url + * @return bool + */ private function testRemoteUrl($url) { + $cache = $this->memcacheFactory->create('files_sharing_remote_url'); + if($result = $cache->get($url)) { + return (bool)$result; + } + $result = file_get_contents($url); $data = json_decode($result); - return (is_object($data) and !empty($data->version)); + $returnValue = (is_object($data) and !empty($data->version)); + $cache->set($url, $returnValue); + return $returnValue; } /** |