Passed
Push — master ( fd0d63...16794a )
by smiley
01:53
created

APCUCache::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Class APCUCache
4
 *
5
 * @filesource   APCUCache.php
6
 * @created      27.05.2017
7
 * @package      chillerlan\SimpleCache
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2017 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\SimpleCache;
14
15
class APCUCache extends CacheDriverAbstract{
16
17
	/** @inheritdoc */
18
	public function get($key, $default = null){
19
		$this->checkKey($key);
20
21
		$value = apcu_fetch($key);
22
23
		if($value !== false){
24
			return $value;
25
		}
26
27
		return $default;
28
	}
29
30
	/** @inheritdoc */
31
	public function set($key, $value, $ttl = null):bool{
32
		$this->checkKey($key);
33
34
		return (bool)apcu_store($key, $value, $this->getTTL($ttl));
35
	}
36
37
	/** @inheritdoc */
38
	public function delete($key):bool{
39
		$this->checkKey($key);
40
41
		return (bool)apcu_delete($key);
42
	}
43
44
	/** @inheritdoc */
45
	public function clear():bool{
46
		return apcu_clear_cache();
47
	}
48
49
}
50