Completed
Push — 1.x ( 378c34...640f8a )
by Akihito
12s
created

ProdCacheProvider::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the BEAR.Package package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\Package\Context\Provider;
8
9
use BEAR\AppMeta\AbstractAppMeta;
10
use Doctrine\Common\Cache\ApcuCache;
11
use Doctrine\Common\Cache\ChainCache;
12
use Doctrine\Common\Cache\FilesystemCache;
13
use Ray\Di\Di\Named;
14
use Ray\Di\ProviderInterface;
15
16
class ProdCacheProvider implements ProviderInterface
17
{
18
    /**
19
     * @var string
20
     */
21
    private $namespace;
22
23
    /**
24
     * @var string
25
     */
26
    private $cacheDir;
27
28
    /**
29
     * @Named("namespace=cache_namespace")
30
     */
31
    public function __construct(AbstractAppMeta $appMeta, $namespace)
32
    {
33
        $this->cacheDir = $appMeta->tmpDir . '/cache';
34
        $this->namespace = $namespace;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function get()
41
    {
42
        $cache = new ChainCache([new ApcuCache, new FilesystemCache($this->cacheDir)]);
43
        $cache->setNamespace($this->namespace);
44
45
        return $cache;
46
    }
47
}
48