Completed
Push — 2.1 ( 28b26f...4d9204 )
by Alexander
10:53
created

ZendDataCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 35
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 4 1
A deleteValue() 0 4 1
A clear() 0 4 1
A getValue() 0 5 2
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\caching;
9
10
/**
11
 * ZendDataCache provides Zend data caching in terms of an application component.
12
 *
13
 * To use this application component, the [Zend Data Cache PHP extension](http://www.zend.com/en/products/server/)
14
 * must be loaded.
15
 *
16
 * Application configuration example:
17
 *
18
 * ```php
19
 * return [
20
 *     'components' => [
21
 *         'cache' => [
22
 *             'class' => yii\caching\Cache::class,
23
 *             'handler' => [
24
 *                 'class' => yii\caching\ZendDataCache::class,
25
 *             ],
26
 *         ],
27
 *         // ...
28
 *     ],
29
 *     // ...
30
 * ];
31
 * ```
32
 *
33
 * See [[\Psr\SimpleCache\CacheInterface]] for common cache operations that ZendDataCache supports.
34
 *
35
 * For more details and usage information on Cache, see the [guide article on caching](guide:caching-overview).
36
 *
37
 * @author Qiang Xue <[email protected]>
38
 * @since 2.0
39
 */
40
class ZendDataCache extends SimpleCache
41
{
42
    /**
43
     * {@inheritdoc}
44
     */
45
    protected function getValue($key)
46
    {
47
        $result = zend_shm_cache_fetch($key);
48
        return $result === null ? false : $result;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    protected function setValue($key, $value, $ttl)
55
    {
56
        return zend_shm_cache_store($key, $value, $ttl);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    protected function deleteValue($key)
63
    {
64
        return zend_shm_cache_delete($key);
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function clear()
71
    {
72
        return zend_shm_cache_clear();
73
    }
74
}
75