ApcuStore::inc()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
/**
3
 * APCu store.
4
 *
5
 * @package SugiPHP.Cache
6
 * @author  Plamen Popov <[email protected]>
7
 * @license http://opensource.org/licenses/mit-license.php (MIT License)
8
 */
9
10
namespace SugiPHP\Cache;
11
12
class ApcuStore implements StoreInterface, IncrementorInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function add($key, $value, $ttl = 0)
18
    {
19
        $res = apcu_add($key, $value, $ttl);
20
21
        return $res;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function set($key, $value, $ttl = 0)
28
    {
29
        $res = apcu_store($key, $value, $ttl);
30
31
        return $res;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function get($key)
38
    {
39
        $success = null;
40
        $result = apcu_fetch($key, $success);
41
42
        if (!$success) {
43
            return null;
44
        }
45
46
        return $result;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function has($key)
53
    {
54
        if (!apcu_exists($key)) {
55
            return false;
56
        }
57
58
        return true;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function delete($key)
65
    {
66
        apcu_delete($key);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function flush()
73
    {
74
        apcu_clear_cache();
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function inc($key, $step = 1)
81
    {
82
        return apcu_inc($key, $step);
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function dec($key, $step = 1)
89
    {
90
        return apcu_dec($key, $step);
91
    }
92
}
93