APCUCache::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 1
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
 * @noinspection PhpComposerExtensionStubsInspection
13
 */
14
15
namespace chillerlan\SimpleCache;
16
17
use function apcu_clear_cache, apcu_delete, apcu_fetch, apcu_store;
18
19
class APCUCache extends CacheDriverAbstract{
20
21
	/** @inheritdoc */
22
	public function get($key, $default = null){
23
		$value = apcu_fetch($this->checkKey($key));
24
25
		if($value !== false){
26
			return $value;
27
		}
28
29
		return $default;
30
	}
31
32
	/** @inheritdoc */
33
	public function set($key, $value, $ttl = null):bool{
34
		return (bool)apcu_store($this->checkKey($key), $value, $this->getTTL($ttl) ?? 0);
35
	}
36
37
	/** @inheritdoc */
38
	public function delete($key):bool{
39
		return (bool)apcu_delete($this->checkKey($key));
40
	}
41
42
	/** @inheritdoc */
43
	public function clear():bool{
44
		return apcu_clear_cache();
45
	}
46
47
}
48