mirror of
https://github.com/flextype/flextype.git
synced 2025-08-09 22:56:46 +02:00
feat(core): add PhpFileAdapter for PHPFile Cache and set PhpFile Cache as a default fallback cache driver instead of Filesystem Cache driver
This commit is contained in:
28
src/flextype/app/Foundation/Cache/PhpFileAdapter.php
Normal file
28
src/flextype/app/Foundation/Cache/PhpFileAdapter.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Flextype\App\Foundation\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\PhpFileCache;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
class PhpFileAdapter implements CacheAdapterInterface
|
||||
{
|
||||
public function __construct(ContainerInterface $flextype)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
}
|
||||
|
||||
public function getDriver() : object
|
||||
{
|
||||
$cache_directory = PATH['cache'] . '/doctrine/';
|
||||
|
||||
if (! Filesystem::has($cache_directory)) {
|
||||
Filesystem::createDir($cache_directory);
|
||||
}
|
||||
|
||||
return new PhpFileCache($cache_directory);
|
||||
}
|
||||
}
|
@@ -112,7 +112,7 @@ $flextype['cache_adapter'] = function ($container) use ($flextype) {
|
||||
} elseif (extension_loaded('wincache')) {
|
||||
$driver_name = 'wincache';
|
||||
} else {
|
||||
$driver_name = 'filesystem';
|
||||
$driver_name = 'PhpFile';
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user