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

ProdCacheProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A get() 0 7 1
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