|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of Phpfastcache. |
|
6
|
|
|
* |
|
7
|
|
|
* @license MIT License (MIT) |
|
8
|
|
|
* |
|
9
|
|
|
* For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files. |
|
10
|
|
|
* |
|
11
|
|
|
* @author Georges.L (Geolim4) <[email protected]> |
|
12
|
|
|
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
declare(strict_types=1); |
|
16
|
|
|
|
|
17
|
|
|
namespace Phpfastcache\Entities; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @see https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV5%CB%96%5D-The-cache-statistics |
|
21
|
|
|
*/ |
|
22
|
|
|
class DriverStatistic |
|
23
|
|
|
{ |
|
24
|
|
|
protected string $info = ''; |
|
25
|
|
|
|
|
26
|
|
|
protected ?int $size = 0; |
|
27
|
|
|
|
|
28
|
|
|
protected ?int $count = 0; |
|
29
|
|
|
|
|
30
|
|
|
protected string $data = ''; |
|
31
|
|
|
|
|
32
|
|
|
protected mixed $rawData; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Return quick information about the driver instance |
|
36
|
|
|
* @return string |
|
37
|
|
|
*/ |
|
38
|
|
|
public function getInfo(): string |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->info; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function setInfo(string $info): static |
|
44
|
|
|
{ |
|
45
|
|
|
$this->info = $info; |
|
46
|
|
|
|
|
47
|
|
|
return $this; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Return the approximate size taken by the driver instance (in bytes) (null if unsupported by the driver) |
|
52
|
|
|
* @return int|null |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getSize(): ?int |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->size; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setSize(?int $size): static |
|
60
|
|
|
{ |
|
61
|
|
|
$this->size = $size; |
|
62
|
|
|
|
|
63
|
|
|
return $this; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Return the approximate count of elements stored in a driver database (or collection if applicable). Added in v9.2.3 |
|
68
|
|
|
* @since 9.2.3 |
|
69
|
|
|
* @return int|null |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getCount(): ?int |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->count; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function setCount(?int $count): static |
|
77
|
|
|
{ |
|
78
|
|
|
$this->count = $count; |
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Return an array of item keys used by this driver instance (deprecated as of v9.2.3, will be removed as of v10) |
|
84
|
|
|
* @deprecated as of phpfastcache 9.2.3, will be removed as of v10 |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getData(): string |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->data; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @deprecated as of phpfastcache 9.2.3, will be removed as of v10 |
|
93
|
|
|
*/ |
|
94
|
|
|
public function setData(string $data): static |
|
95
|
|
|
{ |
|
96
|
|
|
$this->data = ($data ?: ''); |
|
97
|
|
|
|
|
98
|
|
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Return a bunch of random data provided by the driver. Any type can be provided, usually an array |
|
103
|
|
|
* @return mixed |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getRawData(): mixed |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->rawData; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function setRawData(mixed $raw): static |
|
111
|
|
|
{ |
|
112
|
|
|
$this->rawData = $raw; |
|
113
|
|
|
|
|
114
|
|
|
return $this; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @return array<string, string> |
|
119
|
|
|
*/ |
|
120
|
|
|
public function getPublicDesc(): array |
|
121
|
|
|
{ |
|
122
|
|
|
return [ |
|
123
|
|
|
'Info' => 'Cache Information', |
|
124
|
|
|
'Size' => 'Cache Size', |
|
125
|
|
|
'Count' => 'Cache database/collection count', |
|
126
|
|
|
'Data' => 'Cache items keys (Deprecated)', |
|
127
|
|
|
'RawData' => 'Cache raw data', |
|
128
|
|
|
]; |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|