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
This commit is contained in:
parent
8be6054e5c
commit
63bd6b25db
1 changed files with 19 additions and 2 deletions
21
apps/files_sharing/lib/external/storage.php
vendored
21
apps/files_sharing/lib/external/storage.php
vendored
|
@ -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 {
|
||||||
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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue