Merge pull request #22884 from owncloud/backport-cache-results

[stable9] Cache results of testRemoteUrl
This commit is contained in:
Thomas Müller 2016-03-06 19:57:53 +01:00
commit 6f4712a314

View file

@ -54,6 +54,11 @@ class Storage extends DAV implements ISharedStorage {
*/
private $token;
/**
* @var \OCP\ICacheFactory
*/
private $memcacheFactory;
/**
* @var \OCP\ICertificateManager
*/
@ -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;
}
/**