From a0028a2a5f7f4df3f38eef2ba1a4552ff90f0269 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 6 Apr 2018 12:24:41 +0200 Subject: [PATCH] Allow to skip retrieving from cache in the DiscoveryService Signed-off-by: Roeland Jago Douma --- lib/private/OCS/DiscoveryService.php | 15 +++++++++------ lib/public/OCS/IDiscoveryService.php | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/private/OCS/DiscoveryService.php b/lib/private/OCS/DiscoveryService.php index 016331e908..6662263fb7 100644 --- a/lib/private/OCS/DiscoveryService.php +++ b/lib/private/OCS/DiscoveryService.php @@ -59,15 +59,18 @@ class DiscoveryService implements IDiscoveryService { * * @param string $remote * @param string $service the service you want to discover + * @param bool $skipCache We won't check if the data is in the cache. This is usefull if a background job is updating the status * @return array */ - public function discover(string $remote, string $service): array { + public function discover(string $remote, string $service, bool $skipCache = false): array { // Check the cache first - $cacheData = $this->cache->get($remote . '#' . $service); - if($cacheData) { - $data = json_decode($cacheData, true); - if (\is_array($data)) { - return $data; + if ($skipCache === false) { + $cacheData = $this->cache->get($remote . '#' . $service); + if ($cacheData) { + $data = json_decode($cacheData, true); + if (\is_array($data)) { + return $data; + } } } diff --git a/lib/public/OCS/IDiscoveryService.php b/lib/public/OCS/IDiscoveryService.php index 9a86e2a441..704840cf7b 100644 --- a/lib/public/OCS/IDiscoveryService.php +++ b/lib/public/OCS/IDiscoveryService.php @@ -44,8 +44,9 @@ interface IDiscoveryService { * * @param string $remote * @param string $service the service you want to discover + * @param bool $skipCache We won't check if the data is in the cache. This is usefull if a background job is updating the status * @return array */ - public function discover(string $remote, string $service): array; + public function discover(string $remote, string $service, bool $skipCache = false): array; }