1 | <?php |
||
24 | class ProdModule extends AbstractModule |
||
25 | { |
||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | 1 | protected function configure() |
|
30 | { |
||
31 | 1 | if (function_exists('apcu_fetch') && class_exists(ApcuCache::class)) { |
|
32 | $this->installApcCache(ApcuCache::class); |
||
33 | |||
34 | return; |
||
35 | } |
||
36 | 1 | if (function_exists('apc_fetch')) { |
|
37 | $this->installApcCache(ApcCache::class); |
||
38 | |||
39 | return; |
||
40 | } |
||
41 | 1 | $this->installFileCache(); |
|
42 | |||
43 | 1 | } |
|
44 | |||
45 | private function installApcCache($apcClass) |
||
46 | { |
||
47 | $this->bind(Cache::class)->to($apcClass)->in(Scope::SINGLETON); |
||
48 | $this->bind(Reader::class)->toConstructor( |
||
49 | CachedReader::class, |
||
50 | 'reader=annotation_reader' |
||
51 | ); |
||
52 | $this->bind(Reader::class)->annotatedWith('annotation_reader')->to(AnnotationReader::class); |
||
53 | $this->bind(CacheProvider::class)->annotatedWith(Storage::class)->to($apcClass)->in(Scope::SINGLETON); |
||
54 | $this->bind(Cache::class)->annotatedWith(LogicCache::class)->to($apcClass)->in(Scope::SINGLETON); |
||
55 | $this->bind(Cache::class)->annotatedWith(Storage::class)->to($apcClass)->in(Scope::SINGLETON); |
||
56 | } |
||
57 | |||
58 | 1 | private function installFileCache() |
|
70 | } |
||
71 |