1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* This file is part of phpFastCache. |
5
|
|
|
* |
6
|
|
|
* @license MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* For full copyright and license information, please see the docs/CREDITS.txt file. |
9
|
|
|
* |
10
|
|
|
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com |
11
|
|
|
* @author Georges.L (Geolim4) <[email protected]> |
12
|
|
|
* |
13
|
|
|
*/ |
14
|
|
|
declare(strict_types=1); |
15
|
|
|
|
16
|
|
|
namespace Phpfastcache\Drivers\Devnull; |
17
|
|
|
|
18
|
|
|
use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
19
|
|
|
use Phpfastcache\Entities\DriverStatistic; |
20
|
|
|
use Phpfastcache\Exceptions\{ |
21
|
|
|
PhpfastcacheInvalidArgumentException |
22
|
|
|
}; |
23
|
|
|
use Psr\Cache\CacheItemInterface; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class Driver |
27
|
|
|
* @package phpFastCache\Drivers |
28
|
|
|
* @property Config $config Config object |
29
|
|
|
* @method Config getConfig() Return the config object |
30
|
|
|
*/ |
31
|
|
|
class Driver implements ExtendedCacheItemPoolInterface |
32
|
|
|
{ |
33
|
|
|
use DriverBaseTrait; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @return bool |
37
|
|
|
*/ |
38
|
|
|
public function driverCheck(): bool |
39
|
|
|
{ |
40
|
|
|
return true; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param \Psr\Cache\CacheItemInterface $item |
45
|
|
|
* @return mixed |
46
|
|
|
* @throws PhpfastcacheInvalidArgumentException |
47
|
|
|
*/ |
48
|
|
|
protected function driverWrite(CacheItemInterface $item): bool |
49
|
|
|
{ |
50
|
|
|
/** |
51
|
|
|
* Check for Cross-Driver type confusion |
52
|
|
|
*/ |
53
|
|
|
if ($item instanceof Item) { |
54
|
|
|
return true; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param \Psr\Cache\CacheItemInterface $item |
62
|
|
|
* @return null |
63
|
|
|
*/ |
64
|
|
|
protected function driverRead(CacheItemInterface $item) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
return null; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param \Psr\Cache\CacheItemInterface $item |
71
|
|
|
* @return bool |
72
|
|
|
* @throws PhpfastcacheInvalidArgumentException |
73
|
|
|
*/ |
74
|
|
|
protected function driverDelete(CacheItemInterface $item): bool |
75
|
|
|
{ |
76
|
|
|
/** |
77
|
|
|
* Check for Cross-Driver type confusion |
78
|
|
|
*/ |
79
|
|
|
if ($item instanceof Item) { |
80
|
|
|
return true; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return bool |
88
|
|
|
*/ |
89
|
|
|
protected function driverClear(): bool |
90
|
|
|
{ |
91
|
|
|
return true; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return bool |
96
|
|
|
*/ |
97
|
|
|
protected function driverConnect(): bool |
98
|
|
|
{ |
99
|
|
|
return true; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @inheritdoc |
104
|
|
|
*/ |
105
|
|
|
public static function isUsableInAutoContext(): bool |
106
|
|
|
{ |
107
|
|
|
return false; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/******************** |
111
|
|
|
* |
112
|
|
|
* PSR-6 Extended Methods |
113
|
|
|
* |
114
|
|
|
*******************/ |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return DriverStatistic |
118
|
|
|
*/ |
119
|
|
|
public function getStats(): DriverStatistic |
120
|
|
|
{ |
121
|
|
|
$stat = new DriverStatistic(); |
122
|
|
|
$stat->setInfo('[Devnull] A void info string') |
123
|
|
|
->setSize(0) |
124
|
|
|
->setData(\implode(', ', \array_keys($this->itemInstances))) |
125
|
|
|
->setRawData(null); |
126
|
|
|
|
127
|
|
|
return $stat; |
128
|
|
|
} |
129
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.