feat: add config option "path" for file cache (#3297)

This commit is contained in:
Dag 2023-03-20 19:10:01 +01:00 committed by GitHub
parent 4e616c7092
commit 9e9a697b8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 27 deletions

31
tests/CacheTest.php Normal file
View file

@ -0,0 +1,31 @@
<?php
namespace RssBridge\Tests;
use PHPUnit\Framework\TestCase;
class CacheTest extends TestCase
{
public function testFileCache()
{
$temporaryFolder = sprintf('%s/rss_bridge_%s/', sys_get_temp_dir(), create_random_string());
mkdir($temporaryFolder);
$sut = new \FileCache([
'path' => $temporaryFolder,
'enable_purge' => true,
]);
$sut->setScope('scope');
$sut->purgeCache(-1);
$sut->setKey(['key']);
$this->assertNull($sut->loadData());
$sut->saveData('data');
$this->assertSame('data', $sut->loadData());
$this->assertIsNumeric($sut->getTime());
$sut->purgeCache(-1);
// Intentionally not deleting the temp folder
}
}