Completed
Push — master ( 31750b...5f0633 )
by Ryan
07:24
created

CacheAdapter::fetch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Anomaly\Streams\Platform\View\Cache;
2
3
use Asm89\Twig\CacheExtension\CacheProviderInterface;
4
use Illuminate\Contracts\Cache\Repository;
5
use Illuminate\Contracts\Cache\Store;
6
7
/**
8
 * Class CacheAdapter
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 * @package       Anomaly\Streams\Platform\View\Cache
14
 */
15
class CacheAdapter implements CacheProviderInterface
16
{
17
18
    /**
19
     * The cache repository.
20
     *
21
     * @var Repository
22
     */
23
    protected $cache;
24
25
    /**
26
     * Create a new cache adapter.
27
     *
28
     * @param Repository $cache
29
     */
30
    public function __construct(Repository $cache)
31
    {
32
        $this->cache = $cache;
33
    }
34
35
    /**
36
     * Get the cached value.
37
     *
38
     * @param string $key
39
     * @return mixed
40
     */
41
    public function fetch($key)
42
    {
43
        return $this->cache->get($key, false);
44
    }
45
46
    /**
47
     * Put the cached value.
48
     *
49
     * @param string $key
50
     * @param string $value
51
     * @param int    $lifetime
52
     */
53
    public function save($key, $value, $lifetime = 0)
54
    {
55
        $this->cache->put($key, $value, $lifetime);
56
    }
57
}
58