2018-07-07 17:46:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace Friendica\Test\src\Core\Cache;
|
|
|
|
|
|
|
|
|
|
|
|
use Friendica\Core\Cache\CacheDriverFactory;
|
|
|
|
|
2018-07-07 18:35:42 +00:00
|
|
|
class RedisCacheDriverTest extends MemoryCacheTest
|
2018-07-07 17:46:16 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Friendica\Core\Cache\IMemoryCacheDriver
|
|
|
|
*/
|
|
|
|
private $cache;
|
|
|
|
|
|
|
|
protected function getInstance()
|
|
|
|
{
|
|
|
|
if (class_exists('Redis')) {
|
|
|
|
try {
|
|
|
|
$this->cache = CacheDriverFactory::create('redis');
|
|
|
|
} catch (\Exception $exception) {
|
2018-07-08 05:46:06 +00:00
|
|
|
throw new \Exception("Redis - TestCase failed: " . $exception->getMessage(), $exception->getCode(), $exception);
|
2018-07-07 17:46:16 +00:00
|
|
|
}
|
|
|
|
return $this->cache;
|
|
|
|
} else {
|
|
|
|
$this->markTestSkipped('Redis driver isn\'t available');
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
if (class_exists('Redis')) {
|
2018-07-07 18:35:42 +00:00
|
|
|
$this->cache->clear(false);
|
2018-07-07 17:46:16 +00:00
|
|
|
}
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
}
|