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\Devfalse; |
17
|
|
|
|
18
|
|
|
use Phpfastcache\Core\Pool\{ |
19
|
|
|
DriverBaseTrait, ExtendedCacheItemPoolInterface |
20
|
|
|
}; |
21
|
|
|
use Phpfastcache\Entities\DriverStatistic; |
22
|
|
|
use Phpfastcache\Exceptions\{ |
23
|
|
|
PhpfastcacheInvalidArgumentException |
24
|
|
|
}; |
25
|
|
|
use Psr\Cache\CacheItemInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class Driver |
29
|
|
|
* @package phpFastCache\Drivers |
30
|
|
|
* @property Config $config Config object |
31
|
|
|
* @method Config getConfig() Return the config object |
32
|
|
|
*/ |
33
|
|
|
class Driver implements ExtendedCacheItemPoolInterface |
34
|
|
|
{ |
35
|
|
|
use DriverBaseTrait; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return bool |
39
|
|
|
*/ |
40
|
|
|
public function driverCheck(): bool |
41
|
|
|
{ |
42
|
|
|
return true; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param \Psr\Cache\CacheItemInterface $item |
47
|
|
|
* @return bool |
48
|
|
|
* @throws PhpfastcacheInvalidArgumentException |
49
|
|
|
*/ |
50
|
|
|
protected function driverWrite(CacheItemInterface $item): bool |
51
|
|
|
{ |
52
|
|
|
/** |
53
|
|
|
* Check for Cross-Driver type confusion |
54
|
|
|
*/ |
55
|
|
|
if ($item instanceof Item) { |
56
|
|
|
return true; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param \Psr\Cache\CacheItemInterface $item |
64
|
|
|
* @return array |
65
|
|
|
*/ |
66
|
|
|
protected function driverRead(CacheItemInterface $item): array |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
return [ |
69
|
|
|
self::DRIVER_DATA_WRAPPER_INDEX => false, |
70
|
|
|
self::DRIVER_TAGS_WRAPPER_INDEX => [], |
71
|
|
|
self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param \Psr\Cache\CacheItemInterface $item |
77
|
|
|
* @return bool |
78
|
|
|
* @throws PhpfastcacheInvalidArgumentException |
79
|
|
|
*/ |
80
|
|
|
protected function driverDelete(CacheItemInterface $item): bool |
81
|
|
|
{ |
82
|
|
|
/** |
83
|
|
|
* Check for Cross-Driver type confusion |
84
|
|
|
*/ |
85
|
|
|
if ($item instanceof Item) { |
86
|
|
|
return true; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return bool |
94
|
|
|
*/ |
95
|
|
|
protected function driverClear(): bool |
96
|
|
|
{ |
97
|
|
|
return true; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return bool |
102
|
|
|
*/ |
103
|
|
|
protected function driverConnect(): bool |
104
|
|
|
{ |
105
|
|
|
return true; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @inheritdoc |
110
|
|
|
*/ |
111
|
|
|
public static function isUsableInAutoContext(): bool |
112
|
|
|
{ |
113
|
|
|
return false; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/******************** |
117
|
|
|
* |
118
|
|
|
* PSR-6 Extended Methods |
119
|
|
|
* |
120
|
|
|
*******************/ |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return DriverStatistic |
124
|
|
|
*/ |
125
|
|
|
public function getStats(): DriverStatistic |
126
|
|
|
{ |
127
|
|
|
$stat = new DriverStatistic(); |
128
|
|
|
$stat->setInfo('[Devfalse] A void info string') |
129
|
|
|
->setSize(0) |
130
|
|
|
->setData(\implode(', ', \array_keys($this->itemInstances))) |
131
|
|
|
->setRawData(false); |
132
|
|
|
|
133
|
|
|
return $stat; |
134
|
|
|
} |
135
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.