Browse Source

Allow to skip retrieving from cache in the DiscoveryService

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
tags/v14.0.0beta1
Roeland Jago Douma 6 years ago
parent
commit
a0028a2a5f
No account linked to committer's email address
2 changed files with 11 additions and 7 deletions
  1. 9
    6
      lib/private/OCS/DiscoveryService.php
  2. 2
    1
      lib/public/OCS/IDiscoveryService.php

+ 9
- 6
lib/private/OCS/DiscoveryService.php View File

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


+ 2
- 1
lib/public/OCS/IDiscoveryService.php View File

@@ -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;

}

Loading…
Cancel
Save