|
15 | 15 | use ReflectionMethod;
|
16 | 16 | use Symfony\Component\Cache\Adapter\Psr16Adapter;
|
17 | 17 | use Symfony\Contracts\Cache\CacheInterface as CacheContractInterface;
|
18 |
| -use TheCodingMachine\CacheUtils\ClassBoundCache; |
19 |
| -use TheCodingMachine\CacheUtils\ClassBoundCacheContract; |
20 |
| -use TheCodingMachine\CacheUtils\ClassBoundCacheContractInterface; |
21 |
| -use TheCodingMachine\CacheUtils\ClassBoundMemoryAdapter; |
22 |
| -use TheCodingMachine\CacheUtils\FileBoundCache; |
23 | 18 | use TheCodingMachine\GraphQLite\AnnotationReader;
|
| 19 | +use TheCodingMachine\GraphQLite\Cache\ClassBoundCacheContractFactory; |
| 20 | +use TheCodingMachine\GraphQLite\Cache\ClassBoundCacheContractFactoryInterface; |
| 21 | +use TheCodingMachine\GraphQLite\Cache\ClassBoundCacheContractInterface; |
24 | 22 | use TheCodingMachine\GraphQLite\InputTypeGenerator;
|
25 | 23 | use TheCodingMachine\GraphQLite\InputTypeUtils;
|
26 | 24 | use TheCodingMachine\GraphQLite\NamingStrategyInterface;
|
@@ -66,23 +64,15 @@ public function __construct(
|
66 | 64 | private readonly CacheInterface $cache,
|
67 | 65 | protected int|null $globTTL = 2,
|
68 | 66 | private readonly int|null $mapTTL = null,
|
| 67 | + ClassBoundCacheContractFactoryInterface|null $classBoundCacheContractFactory = null, |
69 | 68 | )
|
70 | 69 | {
|
71 | 70 | $this->cacheContract = new Psr16Adapter($this->cache, $cachePrefix, $this->globTTL ?? 0);
|
72 | 71 |
|
73 |
| - $classToAnnotationsCache = new ClassBoundCache( |
74 |
| - new FileBoundCache($this->cache, 'classToAnnotations_' . $cachePrefix), |
75 |
| - ); |
76 |
| - $this->mapClassToAnnotationsCache = new ClassBoundCacheContract( |
77 |
| - new ClassBoundMemoryAdapter($classToAnnotationsCache), |
78 |
| - ); |
79 |
| - |
80 |
| - $classToExtendedAnnotationsCache = new ClassBoundCache( |
81 |
| - new FileBoundCache($this->cache, 'classToExtendAnnotations_' . $cachePrefix), |
82 |
| - ); |
83 |
| - $this->mapClassToExtendAnnotationsCache = new ClassBoundCacheContract( |
84 |
| - new ClassBoundMemoryAdapter($classToExtendedAnnotationsCache), |
85 |
| - ); |
| 72 | + $classBoundCacheContractFactory = $classBoundCacheContractFactory ?? new ClassBoundCacheContractFactory(); |
| 73 | + |
| 74 | + $this->mapClassToAnnotationsCache = $classBoundCacheContractFactory->make($cache, 'classToAnnotations_' . $cachePrefix); |
| 75 | + $this->mapClassToExtendAnnotationsCache = $classBoundCacheContractFactory->make($cache, 'classToExtendAnnotations_' . $cachePrefix); |
86 | 76 | }
|
87 | 77 |
|
88 | 78 | /**
|
|
0 commit comments