Completed
Push — 8.x-1.x ( 980b0f...36574f )
by
unknown
27:24
created

DrupalCache::doSave()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Drupal\controller_annotations\Cache;
4
5
use Doctrine\Common\Cache\Cache;
6
use Doctrine\Common\Cache\CacheProvider;
7
use Drupal\Core\Cache\CacheBackendInterface;
8
9
class DrupalCache extends CacheProvider
10
{
11
    /**
12
     * @var CacheBackendInterface
13
     */
14
    private $cache;
15
16
    /**
17
     * @param CacheBackendInterface $cache
18
     */
19 5
    public function __construct(CacheBackendInterface $cache)
20
    {
21 5
        $this->cache = $cache;
22 5
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27 5
    protected function doFetch($id)
28
    {
29 5
        return $this->cache->get($id);
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    protected function doContains($id)
36
    {
37
        return $this->fetch($id) !== false;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43 5
    protected function doSave($id, $data, $lifeTime = 0)
44
    {
45 5
        $this->cache->set($id, $data, time() + $lifeTime);
46 5
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    protected function doDelete($id)
52
    {
53
        $this->cache->delete($id);
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    protected function doFlush()
60
    {
61
        $this->cache->deleteAll();
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    protected function doGetStats()
68
    {
69
        return array(
70
            Cache::STATS_HITS               => null,
71
            Cache::STATS_MISSES             => null,
72
            Cache::STATS_UPTIME             => null,
73
            Cache::STATS_MEMORY_USAGE       => null,
74
            Cache::STATS_MEMORY_AVAILABLE   => null,
75
        );
76
    }
77
}
78