Completed
Branch master (89d155)
by Dan
14:32 queued 12:04
created

ApcStorage::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Rs\Cache;
4
5
/**
6
 * Class MemcacheStorage
7
 * @package Rs\Cache
8
 */
9
class ApcStorage implements CacheStorageInterface
10
{
11
    private $enabled = false;
12
13
    public function __construct()
14
    {
15
        $this->enabled = extension_loaded('apc');
16
    }
17
18
    /**
19
     * @param string $key
20
     * @return bool
21
     */
22
    public function has($key){
23
        return \apc_exists($key);
24
    }
25
26
    /**
27
     * @param string $key
28
     * @param mixed $value
29
     * @param int $expires
30
     * @return void
31
     */
32
    public function set($key, $value, $expires)
33
    {
34
        \apc_store($key, $value, $expires);
35
    }
36
37
    /**
38
     * @param string $key
39
     * @return mixed
40
     */
41
    public function get($key)
42
    {
43
        return \apc_fetch($key);
44
    }
45
46
    /**
47
     * @param string $key
48
     * @return void
49
     */
50
    public function delete($key)
51
    {
52
        if (\apc_exists($key)){
53
            \apc_delete($key);
54
        }
55
    }
56
57
}
58