Skip to content

Commit

Permalink
Merge pull request #22884 from owncloud/backport-cache-results
Browse files Browse the repository at this point in the history
[stable9] Cache results of testRemoteUrl
  • Loading branch information
DeepDiver1975 committed Mar 6, 2016
2 parents d043b6b + 71e3f7f commit 6f4712a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions apps/files_sharing/lib/external/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class Storage extends DAV implements ISharedStorage {
*/
private $token;

/**
* @var \OCP\ICacheFactory
*/
private $memcacheFactory;

/**
* @var \OCP\ICertificateManager
*/
Expand All @@ -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()
);

Expand Down Expand Up @@ -241,10 +247,21 @@ protected function testRemote() {
}
}

/**
* @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;
}

/**
Expand Down

0 comments on commit 6f4712a

Please sign in to comment.