]> source.dussan.org Git - nextcloud-server.git/commitdiff
Cache appstore requests for 60 instead of 5 minutes
authorMorris Jobke <hey@morrisjobke.de>
Tue, 19 May 2020 21:04:25 +0000 (23:04 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 20 May 2020 07:51:06 +0000 (09:51 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
lib/private/App/AppStore/Fetcher/Fetcher.php
tests/lib/App/AppStore/Fetcher/FetcherBase.php

index 8f2fb0a708448a61ebbd56bd4810cf43ec25ed29..bb39637891f2ca65681a8eb2a398ee0b67ca1f25 100644 (file)
@@ -41,7 +41,7 @@ use OCP\IConfig;
 use OCP\ILogger;
 
 abstract class Fetcher {
-       public const INVALIDATE_AFTER_SECONDS = 300;
+       public const INVALIDATE_AFTER_SECONDS = 3600;
 
        /** @var IAppData */
        protected $appData;
@@ -153,7 +153,7 @@ abstract class Fetcher {
                                // No caching when the version has been updated
                                if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->getVersion()) {
 
-                                       // If the timestamp is older than 300 seconds request the files new
+                                       // If the timestamp is older than 3600 seconds request the files new
                                        if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS)) {
                                                return $jsonBlob['data'];
                                        }
index cfe0af4048305b940ec2bacb2c9c1c95faedb80c..2e04f22760e3588746aace5e5b88da383a67ba63 100644 (file)
@@ -239,7 +239,7 @@ abstract class FetcherBase extends TestCase {
                $this->timeFactory
                        ->expects($this->at(0))
                        ->method('getTime')
-                       ->willReturn(1501);
+                       ->willReturn(4801);
                $client = $this->createMock(IClient::class);
                $this->clientService
                        ->expects($this->once())
@@ -533,11 +533,11 @@ abstract class FetcherBase extends TestCase {
                $this->timeFactory
                        ->expects($this->at(0))
                        ->method('getTime')
-                       ->willReturn(1501);
+                       ->willReturn(4801);
                $this->timeFactory
                        ->expects($this->at(1))
                        ->method('getTime')
-                       ->willReturn(1502);
+                       ->willReturn(4802);
                $client = $this->createMock(IClient::class);
                $this->clientService
                        ->expects($this->once())
@@ -559,7 +559,7 @@ abstract class FetcherBase extends TestCase {
                $response->method('getStatusCode')
                        ->willReturn(304);
 
-               $newData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1502,"ncversion":"11.0.0.2","ETag":"\"myETag\""}';
+               $newData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":4802,"ncversion":"11.0.0.2","ETag":"\"myETag\""}';
                $file
                        ->expects($this->at(1))
                        ->method('putContent')
@@ -638,7 +638,7 @@ abstract class FetcherBase extends TestCase {
                $response->method('getHeader')
                        ->with($this->equalTo('ETag'))
                        ->willReturn('"newETag"');
-               $fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1502,"ncversion":"11.0.0.2","ETag":"\"newETag\""}';
+               $fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":4802,"ncversion":"11.0.0.2","ETag":"\"newETag\""}';
                $file
                        ->expects($this->at(1))
                        ->method('putContent')
@@ -650,11 +650,11 @@ abstract class FetcherBase extends TestCase {
                $this->timeFactory
                        ->expects($this->at(0))
                        ->method('getTime')
-                       ->willReturn(1501);
+                       ->willReturn(4801);
                $this->timeFactory
                        ->expects($this->at(1))
                        ->method('getTime')
-                       ->willReturn(1502);
+                       ->willReturn(4802);
 
                $expected = [
                        [