Skip to content
Snippets Groups Projects
Commit 63bd6b25 authored by Lukas Reschke's avatar Lukas Reschke
Browse files

Cache results of testRemoteUrl

Otherwise setting up the storage will result in a HTTP request and thus slowing down ownCloud.

Replaces https://github.com/owncloud/core/pull/22855
parent 8be6054e
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,11 @@ class Storage extends DAV implements ISharedStorage { ...@@ -54,6 +54,11 @@ class Storage extends DAV implements ISharedStorage {
*/ */
private $token; private $token;
/**
* @var \OCP\ICacheFactory
*/
private $memcacheFactory;
/** /**
* @var \OCP\ICertificateManager * @var \OCP\ICertificateManager
*/ */
...@@ -67,8 +72,9 @@ class Storage extends DAV implements ISharedStorage { ...@@ -67,8 +72,9 @@ class Storage extends DAV implements ISharedStorage {
private $manager; private $manager;
public function __construct($options) { public function __construct($options) {
$this->memcacheFactory = \OC::$server->getMemCacheFactory();
$discoveryManager = new DiscoveryManager( $discoveryManager = new DiscoveryManager(
\OC::$server->getMemCacheFactory(), $this->memcacheFactory,
\OC::$server->getHTTPClientService() \OC::$server->getHTTPClientService()
); );
...@@ -241,10 +247,21 @@ class Storage extends DAV implements ISharedStorage { ...@@ -241,10 +247,21 @@ class Storage extends DAV implements ISharedStorage {
} }
} }
/**
* @param string $url
* @return bool
*/
private function testRemoteUrl($url) { 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); $result = file_get_contents($url);
$data = json_decode($result); $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;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment