Skip to content

Commit

Permalink
Merges master -> feature/performance-improvements-caching
Browse files Browse the repository at this point in the history
  • Loading branch information
weakbit committed Oct 10, 2023
1 parent 8174ac1 commit 2f5adce
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 37 deletions.
44 changes: 13 additions & 31 deletions Build/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="true"
bootstrap="UnitTestsBootstrap.php"
cacheResult="false"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
beStrictAboutTestsThatDoNotTestAnything="false"
failOnWarning="true"
>
<testsuites>
<testsuite name="Unit tests">
<directory>../Tests/Unit/</directory>
</testsuite>
</testsuites>
<php>
<const name="TYPO3_MODE" value="BE" />
<ini name="display_errors" value="1" />
<env name="TYPO3_CONTEXT" value="Testing" />
</php>
</phpunit>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" backupGlobals="true" bootstrap="UnitTestsBootstrap.php" cacheResult="false" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" failOnWarning="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false">
<testsuites>
<testsuite name="Unit tests">
<directory>../Tests/Unit/</directory>
</testsuite>
</testsuites>
<php>
<const name="TYPO3_MODE" value="BE"/>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
</php>
</phpunit>
8 changes: 3 additions & 5 deletions Classes/Driver/AmazonS3Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ class AmazonS3Driver extends AbstractHierarchicalFilesystemDriver implements Str
*
* @var FrontendInterface
*/
protected $metaInfoCache;
protected FrontendInterface $metaInfoCache;

/**
* Generic request -> response cache
* Used for 'listObjectsV2' until now
*
* @var FrontendInterface
*/
protected array $requestCache = [];
protected FrontendInterface $requestCache;

/**
* Object permissions are cached here in subarrays like:
Expand Down Expand Up @@ -1291,9 +1291,7 @@ protected function flushMetaInfoCache($identifier)
*/
protected function resetRequestCache()
{
$this->requestCache = [
'listObjectsV2' => [],
];
$this->requestCache->flush();
}

/**
Expand Down
14 changes: 13 additions & 1 deletion Tests/Unit/Driver/AmazonS3DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Core\ApplicationContext;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class AmazonS3DriverTest
Expand Down Expand Up @@ -83,7 +85,17 @@ public function setUp(): void
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('applicationType')->willReturn(SystemEnvironmentBuilder::REQUESTTYPE_FE);
$GLOBALS['TYPO3_REQUEST'] = $request->reveal();

$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
$cacheManager->setCacheConfigurations([
'ausdriveramazons3_metainfocache' => [
'backend' => \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend::class,
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
],
'ausdriveramazons3_requestcache' => [
'backend' => \TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend::class,
'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class,
]
]);
$this->s3Client = $this->prophesize(S3Client::class);
$eventDispatcher = $this->prophesize(EventDispatcher::class);
$this->driver = new AmazonS3Driver($this->testConfiguration, $this->s3Client->reveal(), $eventDispatcher->reveal());
Expand Down

0 comments on commit 2f5adce

Please sign in to comment.