From 66da5f1ac318ca2d3fc42e5a182f76ecaee05708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20Gangs=C3=B8?= Date: Sun, 16 Feb 2020 14:01:44 +0100 Subject: [PATCH] Add `phpFile` cache option --- config/doctrine.php | 2 +- .../Cache/PhpFileCacheProvider.php | 36 +++++++++++++++++++ .../Cache/PhpFileCacheProviderTest.php | 27 ++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/Configuration/Cache/PhpFileCacheProvider.php create mode 100644 tests/Configuration/Cache/PhpFileCacheProviderTest.php diff --git a/config/doctrine.php b/config/doctrine.php index 8743b874..e0a4eebe 100644 --- a/config/doctrine.php +++ b/config/doctrine.php @@ -157,7 +157,7 @@ | Configure meta-data, query and result caching here. | Optionally you can enable second level caching. | - | Available: apc|array|file|memcached|redis|void + | Available: apc|array|file|memcached|php_file|redis|void | */ 'cache' => [ diff --git a/src/Configuration/Cache/PhpFileCacheProvider.php b/src/Configuration/Cache/PhpFileCacheProvider.php new file mode 100644 index 00000000..0edc6584 --- /dev/null +++ b/src/Configuration/Cache/PhpFileCacheProvider.php @@ -0,0 +1,36 @@ +config = $config; + } + + /** + * @param array $settings + * + * @return PhpFileCache + */ + public function resolve(array $settings = []) + { + return new PhpFileCache( + $this->config->get('cache.stores.file.path', storage_path('framework/cache')) + ); + } +} diff --git a/tests/Configuration/Cache/PhpFileCacheProviderTest.php b/tests/Configuration/Cache/PhpFileCacheProviderTest.php new file mode 100644 index 00000000..ca3b2904 --- /dev/null +++ b/tests/Configuration/Cache/PhpFileCacheProviderTest.php @@ -0,0 +1,27 @@ +shouldReceive('get') + ->with('cache.stores.file.path', __DIR__ . DIRECTORY_SEPARATOR . '../../Stubs/storage/framework/cache') + ->once() + ->andReturn('/tmp'); + + return new PhpFileCacheProvider( + $config + ); + } + + public function getExpectedInstance() + { + return PhpFileCache::class; + } +}