Skip to content

Commit 629dfa2

Browse files
committed
Add phpFile cache option
1 parent ee79c7f commit 629dfa2

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

config/doctrine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
| Configure meta-data, query and result caching here.
158158
| Optionally you can enable second level caching.
159159
|
160-
| Available: apc|array|file|memcached|redis|void
160+
| Available: apc|array|file|memcached|phpFile|redis|void
161161
|
162162
*/
163163
'cache' => [
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace LaravelDoctrine\ORM\Configuration\Cache;
4+
5+
use Doctrine\Common\Cache\FilesystemCache;
6+
use Doctrine\Common\Cache\PhpFileCache;
7+
use Illuminate\Contracts\Config\Repository;
8+
use LaravelDoctrine\ORM\Configuration\Driver;
9+
use function storage_path;
10+
11+
class PhpFileCacheProvider implements Driver
12+
{
13+
/**
14+
* @var Repository
15+
*/
16+
protected $config;
17+
18+
/**
19+
* @param Repository $config
20+
*/
21+
public function __construct(Repository $config)
22+
{
23+
$this->config = $config;
24+
}
25+
26+
/**
27+
* @param array $settings
28+
*
29+
* @return PhpFileCache
30+
*/
31+
public function resolve(array $settings = [])
32+
{
33+
return new PhpFileCache(
34+
$this->config->get('cache.stores.file.path', storage_path('framework/cache'))
35+
);
36+
}
37+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use Doctrine\Common\Cache\PhpFileCache;
4+
use Illuminate\Contracts\Config\Repository;
5+
use LaravelDoctrine\ORM\Configuration\Cache\PhpFileCacheProvider;
6+
use Mockery as m;
7+
8+
class PhpFileCacheProviderTest extends AbstractCacheProviderTest
9+
{
10+
public function getProvider()
11+
{
12+
$config = m::mock(Repository::class);
13+
$config->shouldReceive('get')
14+
->with('cache.stores.file.path', __DIR__ . DIRECTORY_SEPARATOR . '../../Stubs/storage/framework/cache')
15+
->once()
16+
->andReturn('/tmp');
17+
18+
return new PhpFileCacheProvider(
19+
$config
20+
);
21+
}
22+
23+
public function getExpectedInstance()
24+
{
25+
return PhpFileCache::class;
26+
}
27+
}

0 commit comments

Comments
 (0)