@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * Retrieves cache data from the database. |
|
64 | - * |
|
65 | - * @param string $cacheKey |
|
66 | - * @param string $namespace |
|
67 | - * @return mixed |
|
63 | + * Retrieves cache data from the database. |
|
64 | + * |
|
65 | + * @param string $cacheKey |
|
66 | + * @param string $namespace |
|
67 | + * @return mixed |
|
68 | 68 | */ |
69 | 69 | public function retrieve(string $cacheKey, string $namespace = ''): mixed |
70 | 70 | { |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * Get Update query based on the database driver. |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
112 | + * Get Update query based on the database driver. |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | 116 | private function getUpdateQueryWithDriver(): string |
117 | 117 | { |
118 | 118 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | - * Get Delete query based on the database driver. |
|
127 | - * |
|
128 | - * @return string |
|
129 | - */ |
|
126 | + * Get Delete query based on the database driver. |
|
127 | + * |
|
128 | + * @return string |
|
129 | + */ |
|
130 | 130 | private function getDeleteQueryWithDriver(): string |
131 | 131 | { |
132 | 132 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * Updates an existing cache item in the database. |
|
141 | - * |
|
142 | - * @param string $cacheKey |
|
143 | - * @param mixed $cacheData |
|
144 | - * @param string $namespace |
|
145 | - * @return bool |
|
146 | - */ |
|
140 | + * Updates an existing cache item in the database. |
|
141 | + * |
|
142 | + * @param string $cacheKey |
|
143 | + * @param mixed $cacheData |
|
144 | + * @param string $namespace |
|
145 | + * @return bool |
|
146 | + */ |
|
147 | 147 | public function update(string $cacheKey, mixed $cacheData, string $namespace = ''): bool |
148 | 148 | { |
149 | 149 | $query = $this->getUpdateQueryWithDriver(); |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | - * Clears a specific cache item from the database. |
|
161 | - * |
|
162 | - * @param string $cacheKey |
|
163 | - * @param string $namespace |
|
164 | - * @return bool |
|
165 | - */ |
|
160 | + * Clears a specific cache item from the database. |
|
161 | + * |
|
162 | + * @param string $cacheKey |
|
163 | + * @param string $namespace |
|
164 | + * @return bool |
|
165 | + */ |
|
166 | 166 | public function clear(string $cacheKey, string $namespace = ''): bool |
167 | 167 | { |
168 | 168 | $query = $this->getDeleteQueryWithDriver(); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * Gets the query to renew the expiration time of a cache item based on the database driver. |
|
179 | - * |
|
180 | - * @return string |
|
181 | - */ |
|
178 | + * Gets the query to renew the expiration time of a cache item based on the database driver. |
|
179 | + * |
|
180 | + * @return string |
|
181 | + */ |
|
182 | 182 | private function getRenewExpirationQueryWithDriver(): string |
183 | 183 | { |
184 | 184 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | - * Checks if a cache item is valid based on its key, namespace, and current time. |
|
197 | - * |
|
198 | - * @param string $cacheKey |
|
199 | - * @param string $namespace |
|
200 | - * @param string $currentTime |
|
201 | - * @return bool |
|
202 | - */ |
|
196 | + * Checks if a cache item is valid based on its key, namespace, and current time. |
|
197 | + * |
|
198 | + * @param string $cacheKey |
|
199 | + * @param string $namespace |
|
200 | + * @param string $currentTime |
|
201 | + * @return bool |
|
202 | + */ |
|
203 | 203 | private function hasValidCache(string $cacheKey, string $namespace, string $currentTime): bool |
204 | 204 | { |
205 | 205 | $stmt = $this->connection->prepare( |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | - * Renews the expiration time of a cache item. |
|
219 | - * |
|
220 | - * @param string $cacheKey |
|
221 | - * @param string|int $ttl |
|
222 | - * @param string $namespace |
|
223 | - * @return bool |
|
224 | - */ |
|
218 | + * Renews the expiration time of a cache item. |
|
219 | + * |
|
220 | + * @param string $cacheKey |
|
221 | + * @param string|int $ttl |
|
222 | + * @param string $namespace |
|
223 | + * @return bool |
|
224 | + */ |
|
225 | 225 | public function renew(string $cacheKey, string|int $ttl, string $namespace = ''): bool |
226 | 226 | { |
227 | 227 | $currentTime = date('Y-m-d H:i:s'); |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
244 | - * Flushes all cache items from the database. |
|
245 | - * |
|
246 | - * @return bool |
|
247 | - */ |
|
244 | + * Flushes all cache items from the database. |
|
245 | + * |
|
246 | + * @return bool |
|
247 | + */ |
|
248 | 248 | public function flush(): bool |
249 | 249 | { |
250 | 250 | return $this->connection->exec("DELETE FROM cacheer_table") !== false; |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | - * Gets the current date and time based on the database driver. |
|
267 | - * |
|
268 | - * @param string $driver |
|
269 | - * @return string |
|
270 | - */ |
|
266 | + * Gets the current date and time based on the database driver. |
|
267 | + * |
|
268 | + * @param string $driver |
|
269 | + * @return string |
|
270 | + */ |
|
271 | 271 | private function getCurrentDateTime(string $driver): string |
272 | 272 | { |
273 | 273 | return ($driver === 'sqlite') ? "DATETIME('now', 'localtime')" : "NOW()"; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param string|int $ttl |
38 | 38 | * @return bool |
39 | 39 | */ |
40 | - public function store(string $cacheKey, mixed $cacheData, string $namespace, string|int $ttl = 3600): bool |
|
40 | + public function store(string $cacheKey, mixed $cacheData, string $namespace, string | int $ttl = 3600): bool |
|
41 | 41 | { |
42 | 42 | if (!empty($this->retrieve($cacheKey, $namespace))) { |
43 | 43 | return $this->update($cacheKey, $cacheData, $namespace); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param string $namespace |
223 | 223 | * @return bool |
224 | 224 | */ |
225 | - public function renew(string $cacheKey, string|int $ttl, string $namespace = ''): bool |
|
225 | + public function renew(string $cacheKey, string | int $ttl, string $namespace = ''): bool |
|
226 | 226 | { |
227 | 227 | $currentTime = date('Y-m-d H:i:s'); |
228 | 228 | if (!$this->hasValidCache($cacheKey, $namespace, $currentTime)) { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | $query = $this->getRenewExpirationQueryWithDriver(); |
233 | 233 | $stmt = $this->connection->prepare($query); |
234 | - $stmt->bindValue(':ttl', (int) $ttl, PDO::PARAM_INT); |
|
234 | + $stmt->bindValue(':ttl', (int)$ttl, PDO::PARAM_INT); |
|
235 | 235 | $stmt->bindValue(':cacheKey', $cacheKey); |
236 | 236 | $stmt->bindValue(':namespace', $namespace); |
237 | 237 | $stmt->bindValue(':currentTime', $currentTime); |
@@ -12,13 +12,13 @@ |
||
12 | 12 | class OptionBuilder |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Creates a FileOptionBuilder instance for file-based cache options. |
|
17 | - * |
|
18 | - * @return FileOptionBuilder |
|
19 | - */ |
|
20 | - public static function forFile(): FileOptionBuilder |
|
21 | - { |
|
15 | + /** |
|
16 | + * Creates a FileOptionBuilder instance for file-based cache options. |
|
17 | + * |
|
18 | + * @return FileOptionBuilder |
|
19 | + */ |
|
20 | + public static function forFile(): FileOptionBuilder |
|
21 | + { |
|
22 | 22 | return new FileOptionBuilder(); |
23 | - } |
|
23 | + } |
|
24 | 24 | } |
@@ -16,15 +16,15 @@ |
||
16 | 16 | class CacheRetriever |
17 | 17 | { |
18 | 18 | /** |
19 | - * @var Cacheer |
|
20 | - */ |
|
19 | + * @var Cacheer |
|
20 | + */ |
|
21 | 21 | private Cacheer $cacheer; |
22 | 22 | |
23 | 23 | /** |
24 | - * CacheRetriever constructor. |
|
25 | - * |
|
26 | - * @param Cacheer $cacheer |
|
27 | - */ |
|
24 | + * CacheRetriever constructor. |
|
25 | + * |
|
26 | + * @param Cacheer $cacheer |
|
27 | + */ |
|
28 | 28 | public function __construct(Cacheer $cacheer) |
29 | 29 | { |
30 | 30 | $this->cacheer = $cacheer; |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | * @return mixed |
40 | 40 | * @throws CacheFileException |
41 | 41 | */ |
42 | - public function getCache(string $cacheKey, string $namespace = '', int|string $ttl = 3600): mixed |
|
42 | + public function getCache(string $cacheKey, string $namespace = '', int | string $ttl = 3600): mixed |
|
43 | 43 | { |
44 | 44 | $cacheData = $this->cacheer->cacheStore->getCache($cacheKey, $namespace, $ttl); |
45 | 45 | $this->cacheer->syncState(); |
46 | 46 | |
47 | - if ($this->cacheer->isSuccess() && ($this->cacheer->isCompressionEnabled() || $this->cacheer->getEncryptionKey() !== null)) { |
|
47 | + if ($this->cacheer->isSuccess() && ($this->cacheer->isCompressionEnabled() || $this->cacheer->getEncryptionKey() !== null)) { |
|
48 | 48 | $cacheData = CacheerHelper::recoverFromStorage($cacheData, $this->cacheer->isCompressionEnabled(), $this->cacheer->getEncryptionKey()); |
49 | 49 | } |
50 | 50 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return array|CacheDataFormatter |
61 | 61 | * @throws CacheFileException |
62 | 62 | */ |
63 | - public function getMany(array $cacheKeys, string $namespace = '', int|string $ttl = 3600): array|CacheDataFormatter |
|
63 | + public function getMany(array $cacheKeys, string $namespace = '', int | string $ttl = 3600): array | CacheDataFormatter |
|
64 | 64 | { |
65 | 65 | $cachedData = $this->cacheer->cacheStore->getMany($cacheKeys, $namespace, $ttl); |
66 | 66 | return $this->getCachedDatum($cachedData); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return mixed |
110 | 110 | * @throws CacheFileException |
111 | 111 | */ |
112 | - public function remember(string $cacheKey, int|string $ttl, Closure $callback): mixed |
|
112 | + public function remember(string $cacheKey, int | string $ttl, Closure $callback): mixed |
|
113 | 113 | { |
114 | 114 | $cachedData = $this->getCache($cacheKey, ttl: $ttl); |
115 | 115 |
@@ -13,29 +13,29 @@ discard block |
||
13 | 13 | class CacheMutator |
14 | 14 | { |
15 | 15 | /** |
16 | - * @var Cacheer |
|
17 | - */ |
|
16 | + * @var Cacheer |
|
17 | + */ |
|
18 | 18 | private Cacheer $cacheer; |
19 | 19 | |
20 | 20 | /** |
21 | - * CacheMutator constructor. |
|
22 | - * |
|
23 | - * @param Cacheer $cacheer |
|
24 | - */ |
|
21 | + * CacheMutator constructor. |
|
22 | + * |
|
23 | + * @param Cacheer $cacheer |
|
24 | + */ |
|
25 | 25 | public function __construct(Cacheer $cacheer) |
26 | 26 | { |
27 | 27 | $this->cacheer = $cacheer; |
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | - * Adds a cache item if it does not already exist. |
|
32 | - * |
|
33 | - * @param string $cacheKey |
|
34 | - * @param mixed $cacheData |
|
35 | - * @param string $namespace |
|
36 | - * @param int|string $ttl |
|
37 | - * @return bool |
|
38 | - */ |
|
31 | + * Adds a cache item if it does not already exist. |
|
32 | + * |
|
33 | + * @param string $cacheKey |
|
34 | + * @param mixed $cacheData |
|
35 | + * @param string $namespace |
|
36 | + * @param int|string $ttl |
|
37 | + * @return bool |
|
38 | + */ |
|
39 | 39 | public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool |
40 | 40 | { |
41 | 41 | if (!empty($this->cacheer->getCache($cacheKey, $namespace))) { |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Appends data to an existing cache item. |
|
53 | - * |
|
54 | - * @param string $cacheKey |
|
55 | - * @param mixed $cacheData |
|
56 | - * @param string $namespace |
|
57 | - * @return void |
|
58 | - */ |
|
52 | + * Appends data to an existing cache item. |
|
53 | + * |
|
54 | + * @param string $cacheKey |
|
55 | + * @param mixed $cacheData |
|
56 | + * @param string $namespace |
|
57 | + * @return void |
|
58 | + */ |
|
59 | 59 | public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = ''): void |
60 | 60 | { |
61 | 61 | $this->cacheer->cacheStore->appendCache($cacheKey, $cacheData, $namespace); |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * Clears a specific cache item. |
|
67 | - * |
|
68 | - * @param string $cacheKey |
|
69 | - * @param string $namespace |
|
70 | - * @return void |
|
71 | - */ |
|
66 | + * Clears a specific cache item. |
|
67 | + * |
|
68 | + * @param string $cacheKey |
|
69 | + * @param string $namespace |
|
70 | + * @return void |
|
71 | + */ |
|
72 | 72 | public function clearCache(string $cacheKey, string $namespace = ''): void |
73 | 73 | { |
74 | 74 | $this->cacheer->cacheStore->clearCache($cacheKey, $namespace); |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * Decrements a numeric cache item by a specified amount. |
|
80 | - * |
|
81 | - * @param string $cacheKey |
|
82 | - * @param int $amount |
|
83 | - * @param string $namespace |
|
84 | - * @return bool |
|
85 | - */ |
|
79 | + * Decrements a numeric cache item by a specified amount. |
|
80 | + * |
|
81 | + * @param string $cacheKey |
|
82 | + * @param int $amount |
|
83 | + * @param string $namespace |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | 86 | public function decrement(string $cacheKey, int $amount = 1, string $namespace = ''): bool |
87 | 87 | { |
88 | 88 | return $this->increment($cacheKey, ($amount * -1), $namespace); |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | - * Flushes the entire cache. |
|
106 | - * |
|
107 | - * @return void |
|
108 | - */ |
|
105 | + * Flushes the entire cache. |
|
106 | + * |
|
107 | + * @return void |
|
108 | + */ |
|
109 | 109 | public function flushCache(): void |
110 | 110 | { |
111 | 111 | $this->cacheer->cacheStore->flushCache(); |
@@ -150,26 +150,26 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * Puts multiple cache items in a batch. |
|
154 | - * |
|
155 | - * @param array $items |
|
156 | - * @param string $namespace |
|
157 | - * @param int $batchSize |
|
158 | - * @return void |
|
159 | - */ |
|
153 | + * Puts multiple cache items in a batch. |
|
154 | + * |
|
155 | + * @param array $items |
|
156 | + * @param string $namespace |
|
157 | + * @param int $batchSize |
|
158 | + * @return void |
|
159 | + */ |
|
160 | 160 | public function putMany(array $items, string $namespace = '', int $batchSize = 100): void |
161 | 161 | { |
162 | 162 | $this->cacheer->cacheStore->putMany($items, $namespace, $batchSize); |
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * Renews the cache item with a new TTL. |
|
167 | - * |
|
168 | - * @param string $cacheKey |
|
169 | - * @param int|string $ttl |
|
170 | - * @param string $namespace |
|
171 | - * @return void |
|
172 | - */ |
|
166 | + * Renews the cache item with a new TTL. |
|
167 | + * |
|
168 | + * @param string $cacheKey |
|
169 | + * @param int|string $ttl |
|
170 | + * @param string $namespace |
|
171 | + * @return void |
|
172 | + */ |
|
173 | 173 | public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = ''): void |
174 | 174 | { |
175 | 175 | $this->cacheer->cacheStore->renewCache($cacheKey, $ttl, $namespace); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param int|string $ttl |
37 | 37 | * @return bool |
38 | 38 | */ |
39 | - public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool |
|
39 | + public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600): bool |
|
40 | 40 | { |
41 | 41 | if (!empty($this->cacheer->getCache($cacheKey, $namespace))) { |
42 | 42 | return true; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param int|string $ttl |
143 | 143 | * @return void |
144 | 144 | */ |
145 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): void |
|
145 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600): void |
|
146 | 146 | { |
147 | 147 | $data = CacheerHelper::prepareForStorage($cacheData, $this->cacheer->isCompressionEnabled(), $this->cacheer->getEncryptionKey()); |
148 | 148 | $this->cacheer->cacheStore->putCache($cacheKey, $data, $namespace, $ttl); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param string $namespace |
171 | 171 | * @return void |
172 | 172 | */ |
173 | - public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = ''): void |
|
173 | + public function renewCache(string $cacheKey, int | string $ttl = 3600, string $namespace = ''): void |
|
174 | 174 | { |
175 | 175 | $this->cacheer->cacheStore->renewCache($cacheKey, $ttl, $namespace); |
176 | 176 | $this->cacheer->syncState(); |
@@ -13,24 +13,24 @@ discard block |
||
13 | 13 | class TimeBuilder |
14 | 14 | { |
15 | 15 | |
16 | - /** @param Closure $callback */ |
|
17 | - private Closure $callback; |
|
16 | + /** @param Closure $callback */ |
|
17 | + private Closure $callback; |
|
18 | 18 | |
19 | - /** @var ?FileOptionBuilder */ |
|
20 | - private ?FileOptionBuilder $builder = null; |
|
19 | + /** @var ?FileOptionBuilder */ |
|
20 | + private ?FileOptionBuilder $builder = null; |
|
21 | 21 | |
22 | - /** |
|
23 | - * TimeBuilder constructor. |
|
24 | - * @param Closure $callback |
|
25 | - * @param FileOptionBuilder $builder |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function __construct(Closure $callback, FileOptionBuilder $builder) |
|
30 | - { |
|
22 | + /** |
|
23 | + * TimeBuilder constructor. |
|
24 | + * @param Closure $callback |
|
25 | + * @param FileOptionBuilder $builder |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function __construct(Closure $callback, FileOptionBuilder $builder) |
|
30 | + { |
|
31 | 31 | $this->callback = $callback; |
32 | 32 | $this->builder = $builder; |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Sets the time in seconds. |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | * @param int $seconds |
39 | 39 | * @return FileOptionBuilder|null |
40 | 40 | */ |
41 | - public function second(int $seconds): ?FileOptionBuilder |
|
42 | - { |
|
41 | + public function second(int $seconds): ?FileOptionBuilder |
|
42 | + { |
|
43 | 43 | return $this->setTime($seconds, "seconds"); |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Sets the time in minutes. |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @param int $minutes |
50 | 50 | * @return FileOptionBuilder|null |
51 | 51 | */ |
52 | - public function minute(int $minutes): ?FileOptionBuilder |
|
53 | - { |
|
52 | + public function minute(int $minutes): ?FileOptionBuilder |
|
53 | + { |
|
54 | 54 | return $this->setTime($minutes, "minutes"); |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Sets the time in hours. |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | * @param int $hours |
61 | 61 | * @return FileOptionBuilder|null |
62 | 62 | */ |
63 | - public function hour(int $hours): ?FileOptionBuilder |
|
64 | - { |
|
63 | + public function hour(int $hours): ?FileOptionBuilder |
|
64 | + { |
|
65 | 65 | return $this->setTime($hours, "hours"); |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Sets the time in days. |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | * @param int $days |
72 | 72 | * @return FileOptionBuilder|null |
73 | 73 | */ |
74 | - public function day(int $days): ?FileOptionBuilder |
|
75 | - { |
|
74 | + public function day(int $days): ?FileOptionBuilder |
|
75 | + { |
|
76 | 76 | return $this->setTime($days, "days"); |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Sets the time in weeks. |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @param int $weeks |
83 | 83 | * @return FileOptionBuilder|null |
84 | 84 | */ |
85 | - public function week(int $weeks): ?FileOptionBuilder |
|
86 | - { |
|
85 | + public function week(int $weeks): ?FileOptionBuilder |
|
86 | + { |
|
87 | 87 | return $this->setTime($weeks, "weeks"); |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Sets the time in months. |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * @param int $months |
94 | 94 | * @return FileOptionBuilder|null |
95 | 95 | */ |
96 | - public function month(int $months): ?FileOptionBuilder |
|
97 | - { |
|
96 | + public function month(int $months): ?FileOptionBuilder |
|
97 | + { |
|
98 | 98 | return $this->setTime($months, "months"); |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | 102 | /** |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @param string $unit |
107 | 107 | * @return FileOptionBuilder|null |
108 | 108 | */ |
109 | - private function setTime(int $value, string $unit): ?FileOptionBuilder |
|
110 | - { |
|
111 | - ($this->callback)("{$value} {$unit}"); |
|
109 | + private function setTime(int $value, string $unit): ?FileOptionBuilder |
|
110 | + { |
|
111 | + ($this->callback)("{$value} {$unit}"); |
|
112 | 112 | return $this->builder; |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | 115 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | /** |
23 | - * @var Cacheer |
|
24 | - */ |
|
23 | + * @var Cacheer |
|
24 | + */ |
|
25 | 25 | protected Cacheer $cacheer; |
26 | 26 | |
27 | 27 | /** @param string $logPath */ |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | - * Uses the database driver for caching. |
|
42 | - * |
|
43 | - * @return Cacheer |
|
44 | - */ |
|
41 | + * Uses the database driver for caching. |
|
42 | + * |
|
43 | + * @return Cacheer |
|
44 | + */ |
|
45 | 45 | public function useDatabaseDriver(): Cacheer |
46 | 46 | { |
47 | 47 | $this->cacheer->cacheStore = new DatabaseCacheStore($this->logPath); |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Uses the file driver for caching. |
|
53 | - * |
|
54 | - * @return Cacheer |
|
55 | - */ |
|
52 | + * Uses the file driver for caching. |
|
53 | + * |
|
54 | + * @return Cacheer |
|
55 | + */ |
|
56 | 56 | public function useFileDriver(): Cacheer |
57 | 57 | { |
58 | 58 | $this->cacheer->options['loggerPath'] = $this->logPath; |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | - * Uses the Redis driver for caching. |
|
65 | - * |
|
66 | - * @return Cacheer |
|
67 | - */ |
|
64 | + * Uses the Redis driver for caching. |
|
65 | + * |
|
66 | + * @return Cacheer |
|
67 | + */ |
|
68 | 68 | public function useRedisDriver(): Cacheer |
69 | 69 | { |
70 | 70 | $this->cacheer->cacheStore = new RedisCacheStore($this->logPath); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | - * Uses the array driver for caching. |
|
76 | - * |
|
77 | - * @return Cacheer |
|
78 | - */ |
|
75 | + * Uses the array driver for caching. |
|
76 | + * |
|
77 | + * @return Cacheer |
|
78 | + */ |
|
79 | 79 | public function useArrayDriver(): Cacheer |
80 | 80 | { |
81 | 81 | $this->cacheer->cacheStore = new ArrayCacheStore($this->logPath); |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | - * Uses the default driver for caching. |
|
87 | - * |
|
88 | - * @return Cacheer |
|
89 | - */ |
|
86 | + * Uses the default driver for caching. |
|
87 | + * |
|
88 | + * @return Cacheer |
|
89 | + */ |
|
90 | 90 | public function useDefaultDriver(): Cacheer |
91 | 91 | { |
92 | 92 | if (!isset($this->cacheer->options['cacheDir'])) { |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | - * Checks if the directory exists or creates it. |
|
107 | - * |
|
108 | - * @param mixed $dirName |
|
109 | - * @return bool |
|
110 | - */ |
|
106 | + * Checks if the directory exists or creates it. |
|
107 | + * |
|
108 | + * @param mixed $dirName |
|
109 | + * @return bool |
|
110 | + */ |
|
111 | 111 | private function isDir(mixed $dirName): bool |
112 | 112 | { |
113 | - if (is_dir($dirName)) { |
|
114 | - return true; |
|
115 | - } |
|
116 | - return mkdir($dirName, 0755, true); |
|
113 | + if (is_dir($dirName)) { |
|
114 | + return true; |
|
115 | + } |
|
116 | + return mkdir($dirName, 0755, true); |
|
117 | 117 | } |
118 | 118 | } |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | private mixed $data; |
14 | 14 | |
15 | 15 | /** |
16 | - * CacheDataFormatter constructor. |
|
17 | - * |
|
18 | - * @param mixed $data |
|
19 | - */ |
|
16 | + * CacheDataFormatter constructor. |
|
17 | + * |
|
18 | + * @param mixed $data |
|
19 | + */ |
|
20 | 20 | public function __construct(mixed $data) |
21 | 21 | { |
22 | 22 | $this->data = $data; |
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Converts the data to JSON format. |
|
27 | - * |
|
28 | - * @return string|false |
|
29 | - */ |
|
26 | + * Converts the data to JSON format. |
|
27 | + * |
|
28 | + * @return string|false |
|
29 | + */ |
|
30 | 30 | public function toJson(): bool|string |
31 | 31 | { |
32 | 32 | return json_encode( |
@@ -38,30 +38,30 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | - * Converts the data to an array. |
|
42 | - * |
|
43 | - * @return array |
|
44 | - */ |
|
41 | + * Converts the data to an array. |
|
42 | + * |
|
43 | + * @return array |
|
44 | + */ |
|
45 | 45 | public function toArray(): array |
46 | 46 | { |
47 | 47 | return (array)$this->data; |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * Converts the data to a string. |
|
52 | - * |
|
53 | - * @return string |
|
54 | - */ |
|
51 | + * Converts the data to a string. |
|
52 | + * |
|
53 | + * @return string |
|
54 | + */ |
|
55 | 55 | public function toString(): string |
56 | 56 | { |
57 | 57 | return (string)$this->data; |
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | - * Converts the data to an object. |
|
62 | - * |
|
63 | - * @return object |
|
64 | - */ |
|
61 | + * Converts the data to an object. |
|
62 | + * |
|
63 | + * @return object |
|
64 | + */ |
|
65 | 65 | public function toObject(): object |
66 | 66 | { |
67 | 67 | return (object)$this->data; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * |
28 | 28 | * @return string|false |
29 | 29 | */ |
30 | - public function toJson(): bool|string |
|
30 | + public function toJson(): bool | string |
|
31 | 31 | { |
32 | 32 | return json_encode( |
33 | 33 | $this->data, |
@@ -23,40 +23,40 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Logs a info message. |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
26 | + * Logs a info message. |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | 30 | public function info($message): void |
31 | 31 | { |
32 | 32 | $this->log('INFO', $message); |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * Logs a warning message. |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
36 | + * Logs a warning message. |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | 40 | public function warning($message): void |
41 | 41 | { |
42 | 42 | $this->log('WARNING', $message); |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | - * Logs an error message. |
|
47 | - * |
|
48 | - * @return void |
|
49 | - */ |
|
46 | + * Logs an error message. |
|
47 | + * |
|
48 | + * @return void |
|
49 | + */ |
|
50 | 50 | public function error($message): void |
51 | 51 | { |
52 | 52 | $this->log('ERROR', $message); |
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * Logs a debug message. |
|
57 | - * |
|
58 | - * @return void |
|
59 | - */ |
|
56 | + * Logs a debug message. |
|
57 | + * |
|
58 | + * @return void |
|
59 | + */ |
|
60 | 60 | public function debug($message): void |
61 | 61 | { |
62 | 62 | $this->log('DEBUG', $message); |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Rotates the log file if it exceeds the maximum size. |
|
78 | - * |
|
79 | - * @return void |
|
80 | - */ |
|
77 | + * Rotates the log file if it exceeds the maximum size. |
|
78 | + * |
|
79 | + * @return void |
|
80 | + */ |
|
81 | 81 | private function rotateLog(): void |
82 | 82 | { |
83 | 83 | if (file_exists($this->logFile) && filesize($this->logFile) >= $this->maxFileSize) { |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Logs a message to the log file. |
|
91 | - * |
|
92 | - * @param mixed $level |
|
93 | - * @param string $message |
|
94 | - * @return void |
|
95 | - */ |
|
90 | + * Logs a message to the log file. |
|
91 | + * |
|
92 | + * @param mixed $level |
|
93 | + * @param string $message |
|
94 | + * @return void |
|
95 | + */ |
|
96 | 96 | private function log(mixed $level, string $message): void |
97 | 97 | { |
98 | 98 | if (!$this->shouldLog($level)) { |
@@ -23,56 +23,56 @@ discard block |
||
23 | 23 | final class Cacheer implements CacheerInterface |
24 | 24 | { |
25 | 25 | /** |
26 | - * @var string |
|
27 | - */ |
|
26 | + * @var string |
|
27 | + */ |
|
28 | 28 | private string $message; |
29 | 29 | |
30 | 30 | /** |
31 | - * @var boolean |
|
32 | - */ |
|
31 | + * @var boolean |
|
32 | + */ |
|
33 | 33 | private bool $success; |
34 | 34 | |
35 | 35 | /** |
36 | - * @var boolean |
|
37 | - */ |
|
36 | + * @var boolean |
|
37 | + */ |
|
38 | 38 | private bool $formatted = false; |
39 | 39 | |
40 | 40 | /** |
41 | - * @var bool |
|
42 | - */ |
|
41 | + * @var bool |
|
42 | + */ |
|
43 | 43 | private bool $compression = false; |
44 | 44 | |
45 | 45 | /** |
46 | - * @var string|null |
|
47 | - */ |
|
46 | + * @var string|null |
|
47 | + */ |
|
48 | 48 | private ?string $encryptionKey = null; |
49 | 49 | |
50 | 50 | /** |
51 | - * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore |
|
52 | - */ |
|
51 | + * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore |
|
52 | + */ |
|
53 | 53 | public RedisCacheStore|DatabaseCacheStore|ArrayCacheStore|FileCacheStore $cacheStore; |
54 | 54 | |
55 | 55 | /** |
56 | - * @var array |
|
57 | - */ |
|
56 | + * @var array |
|
57 | + */ |
|
58 | 58 | public array $options = []; |
59 | 59 | |
60 | 60 | /** |
61 | - * @var CacheRetriever |
|
62 | - */ |
|
61 | + * @var CacheRetriever |
|
62 | + */ |
|
63 | 63 | private CacheRetriever $retriever; |
64 | 64 | |
65 | 65 | /** |
66 | - * @var CacheMutator |
|
67 | - */ |
|
66 | + * @var CacheMutator |
|
67 | + */ |
|
68 | 68 | private CacheMutator $mutator; |
69 | 69 | |
70 | 70 | /** |
71 | - * Cacheer constructor. |
|
72 | - * |
|
73 | - * @param array $options |
|
74 | - * @param bool $formatted |
|
75 | - * @throws RuntimeException|Exceptions\CacheFileException |
|
71 | + * Cacheer constructor. |
|
72 | + * |
|
73 | + * @param array $options |
|
74 | + * @param bool $formatted |
|
75 | + * @throws RuntimeException|Exceptions\CacheFileException |
|
76 | 76 | */ |
77 | 77 | public function __construct(array $options = [], bool $formatted = false) |
78 | 78 | { |
@@ -84,122 +84,122 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | - * Adds data to the cache if it does not already exist. |
|
88 | - * |
|
89 | - * @param string $cacheKey |
|
90 | - * @param mixed $cacheData |
|
91 | - * @param string $namespace |
|
92 | - * @param int|string $ttl |
|
93 | - * @return bool |
|
94 | - */ |
|
87 | + * Adds data to the cache if it does not already exist. |
|
88 | + * |
|
89 | + * @param string $cacheKey |
|
90 | + * @param mixed $cacheData |
|
91 | + * @param string $namespace |
|
92 | + * @param int|string $ttl |
|
93 | + * @return bool |
|
94 | + */ |
|
95 | 95 | public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool |
96 | 96 | { |
97 | 97 | return $this->mutator->add($cacheKey, $cacheData, $namespace, $ttl); |
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | - * Appends data to an existing cache item. |
|
102 | - * |
|
103 | - * @param string $cacheKey |
|
104 | - * @param mixed $cacheData |
|
105 | - * @param string $namespace |
|
106 | - * @return void |
|
107 | - */ |
|
101 | + * Appends data to an existing cache item. |
|
102 | + * |
|
103 | + * @param string $cacheKey |
|
104 | + * @param mixed $cacheData |
|
105 | + * @param string $namespace |
|
106 | + * @return void |
|
107 | + */ |
|
108 | 108 | public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = ''): void |
109 | 109 | { |
110 | 110 | $this->mutator->appendCache($cacheKey, $cacheData, $namespace); |
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | - * Clears a specific cache item. |
|
115 | - * |
|
116 | - * @param string $cacheKey |
|
117 | - * @param string $namespace |
|
118 | - * @return void |
|
119 | - */ |
|
114 | + * Clears a specific cache item. |
|
115 | + * |
|
116 | + * @param string $cacheKey |
|
117 | + * @param string $namespace |
|
118 | + * @return void |
|
119 | + */ |
|
120 | 120 | public function clearCache(string $cacheKey, string $namespace = ''): void |
121 | 121 | { |
122 | 122 | $this->mutator->clearCache($cacheKey, $namespace); |
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | - * Decrements a cache item by a specified amount. |
|
127 | - * |
|
128 | - * @param string $cacheKey |
|
129 | - * @param int $amount |
|
130 | - * @param string $namespace |
|
131 | - * @return bool |
|
132 | - */ |
|
126 | + * Decrements a cache item by a specified amount. |
|
127 | + * |
|
128 | + * @param string $cacheKey |
|
129 | + * @param int $amount |
|
130 | + * @param string $namespace |
|
131 | + * @return bool |
|
132 | + */ |
|
133 | 133 | public function decrement(string $cacheKey, int $amount = 1, string $namespace = ''): bool |
134 | 134 | { |
135 | 135 | return $this->mutator->decrement($cacheKey, $amount, $namespace); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | - * Store data in the cache permanently. |
|
140 | - * |
|
141 | - * @param string $cacheKey |
|
142 | - * @param mixed $cacheData |
|
143 | - * @return void |
|
144 | - */ |
|
139 | + * Store data in the cache permanently. |
|
140 | + * |
|
141 | + * @param string $cacheKey |
|
142 | + * @param mixed $cacheData |
|
143 | + * @return void |
|
144 | + */ |
|
145 | 145 | public function forever(string $cacheKey, mixed $cacheData): void |
146 | 146 | { |
147 | 147 | $this->mutator->forever($cacheKey, $cacheData); |
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | - * Flushes all cache items. |
|
152 | - * |
|
153 | - * @return void |
|
154 | - */ |
|
151 | + * Flushes all cache items. |
|
152 | + * |
|
153 | + * @return void |
|
154 | + */ |
|
155 | 155 | public function flushCache(): void |
156 | 156 | { |
157 | 157 | $this->mutator->flushCache(); |
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | - * Retrieves a cache item and deletes it from the cache. |
|
162 | - * |
|
163 | - * @param string $cacheKey |
|
164 | - * @param string $namespace |
|
165 | - * @return mixed |
|
166 | - */ |
|
161 | + * Retrieves a cache item and deletes it from the cache. |
|
162 | + * |
|
163 | + * @param string $cacheKey |
|
164 | + * @param string $namespace |
|
165 | + * @return mixed |
|
166 | + */ |
|
167 | 167 | public function getAndForget(string $cacheKey, string $namespace = ''): mixed |
168 | 168 | { |
169 | 169 | return $this->retriever->getAndForget($cacheKey, $namespace); |
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Gets all items in a specific namespace. |
|
174 | - * |
|
175 | - * @param string $namespace |
|
176 | - * @return CacheDataFormatter|mixed |
|
177 | - */ |
|
173 | + * Gets all items in a specific namespace. |
|
174 | + * |
|
175 | + * @param string $namespace |
|
176 | + * @return CacheDataFormatter|mixed |
|
177 | + */ |
|
178 | 178 | public function getAll(string $namespace = ''): mixed |
179 | 179 | { |
180 | 180 | return $this->retriever->getAll($namespace); |
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | - * Retrieves a single cache item. |
|
185 | - * |
|
186 | - * @param string $cacheKey |
|
187 | - * @param string $namespace |
|
188 | - * @param string|int $ttl |
|
189 | - * @return CacheDataFormatter|mixed |
|
190 | - */ |
|
184 | + * Retrieves a single cache item. |
|
185 | + * |
|
186 | + * @param string $cacheKey |
|
187 | + * @param string $namespace |
|
188 | + * @param string|int $ttl |
|
189 | + * @return CacheDataFormatter|mixed |
|
190 | + */ |
|
191 | 191 | public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed |
192 | 192 | { |
193 | 193 | return $this->retriever->getCache($cacheKey, $namespace, $ttl); |
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | - * Retrieves multiple cache items by their keys. |
|
198 | - * |
|
199 | - * @param array $cacheKeys |
|
200 | - * @param string $namespace |
|
201 | - * @param string|int $ttl |
|
202 | - * @return CacheDataFormatter|array |
|
197 | + * Retrieves multiple cache items by their keys. |
|
198 | + * |
|
199 | + * @param array $cacheKeys |
|
200 | + * @param string $namespace |
|
201 | + * @param string|int $ttl |
|
202 | + * @return CacheDataFormatter|array |
|
203 | 203 | */ |
204 | 204 | public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): CacheDataFormatter|array |
205 | 205 | { |
@@ -207,132 +207,132 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | - * Checks if a cache item exists. |
|
211 | - * |
|
212 | - * @param string $cacheKey |
|
213 | - * @param string $namespace |
|
214 | - * @return void |
|
215 | - */ |
|
210 | + * Checks if a cache item exists. |
|
211 | + * |
|
212 | + * @param string $cacheKey |
|
213 | + * @param string $namespace |
|
214 | + * @return void |
|
215 | + */ |
|
216 | 216 | public function has(string $cacheKey, string $namespace = ''): void |
217 | 217 | { |
218 | 218 | $this->retriever->has($cacheKey, $namespace); |
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | - * Increments a cache item by a specified amount. |
|
223 | - * |
|
224 | - * @param string $cacheKey |
|
225 | - * @param int $amount |
|
226 | - * @param string $namespace |
|
227 | - * @return bool |
|
228 | - */ |
|
222 | + * Increments a cache item by a specified amount. |
|
223 | + * |
|
224 | + * @param string $cacheKey |
|
225 | + * @param int $amount |
|
226 | + * @param string $namespace |
|
227 | + * @return bool |
|
228 | + */ |
|
229 | 229 | public function increment(string $cacheKey, int $amount = 1, string $namespace = ''): bool |
230 | 230 | { |
231 | 231 | return $this->mutator->increment($cacheKey, $amount, $namespace); |
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
235 | - * Checks if the last operation was successful. |
|
236 | - * |
|
237 | - * @return bool |
|
238 | - */ |
|
235 | + * Checks if the last operation was successful. |
|
236 | + * |
|
237 | + * @return bool |
|
238 | + */ |
|
239 | 239 | public function isSuccess(): bool |
240 | 240 | { |
241 | 241 | return $this->success; |
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
245 | - * Stores an item in the cache with a specific TTL. |
|
246 | - * |
|
247 | - * @param string $cacheKey |
|
248 | - * @param mixed $cacheData |
|
249 | - * @param string $namespace |
|
250 | - * @param string|int $ttl |
|
251 | - * @return void |
|
252 | - */ |
|
245 | + * Stores an item in the cache with a specific TTL. |
|
246 | + * |
|
247 | + * @param string $cacheKey |
|
248 | + * @param mixed $cacheData |
|
249 | + * @param string $namespace |
|
250 | + * @param string|int $ttl |
|
251 | + * @return void |
|
252 | + */ |
|
253 | 253 | public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): void |
254 | 254 | { |
255 | 255 | $this->mutator->putCache($cacheKey, $cacheData, $namespace, $ttl); |
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | - * Stores multiple items in the cache. |
|
260 | - * |
|
261 | - * @param array $items |
|
262 | - * @param string $namespace |
|
263 | - * @param integer $batchSize |
|
264 | - * @return void |
|
265 | - */ |
|
259 | + * Stores multiple items in the cache. |
|
260 | + * |
|
261 | + * @param array $items |
|
262 | + * @param string $namespace |
|
263 | + * @param integer $batchSize |
|
264 | + * @return void |
|
265 | + */ |
|
266 | 266 | public function putMany(array $items, string $namespace = '', int $batchSize = 100): void |
267 | 267 | { |
268 | 268 | $this->mutator->putMany($items, $namespace, $batchSize); |
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
272 | - * Renews the cache for a specific key with a new TTL. |
|
273 | - * |
|
274 | - * @param string $cacheKey |
|
275 | - * @param string|int $ttl |
|
276 | - * @param string $namespace |
|
277 | - * @return void |
|
278 | - */ |
|
272 | + * Renews the cache for a specific key with a new TTL. |
|
273 | + * |
|
274 | + * @param string $cacheKey |
|
275 | + * @param string|int $ttl |
|
276 | + * @param string $namespace |
|
277 | + * @return void |
|
278 | + */ |
|
279 | 279 | public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = ''): void |
280 | 280 | { |
281 | 281 | $this->mutator->renewCache($cacheKey, $ttl, $namespace); |
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | - * Retrieves a cache item or executes a callback to store it if not found. |
|
286 | - * |
|
287 | - * @param string $cacheKey |
|
288 | - * @param int|string $ttl |
|
289 | - * @param Closure $callback |
|
290 | - * @return mixed |
|
291 | - */ |
|
285 | + * Retrieves a cache item or executes a callback to store it if not found. |
|
286 | + * |
|
287 | + * @param string $cacheKey |
|
288 | + * @param int|string $ttl |
|
289 | + * @param Closure $callback |
|
290 | + * @return mixed |
|
291 | + */ |
|
292 | 292 | public function remember(string $cacheKey, int|string $ttl, Closure $callback): mixed |
293 | 293 | { |
294 | 294 | return $this->retriever->remember($cacheKey, $ttl, $callback); |
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | - * Retrieves a cache item or executes a callback to store it permanently if not found. |
|
299 | - * |
|
300 | - * @param string $cacheKey |
|
301 | - * @param Closure $callback |
|
302 | - * @return mixed |
|
303 | - */ |
|
298 | + * Retrieves a cache item or executes a callback to store it permanently if not found. |
|
299 | + * |
|
300 | + * @param string $cacheKey |
|
301 | + * @param Closure $callback |
|
302 | + * @return mixed |
|
303 | + */ |
|
304 | 304 | public function rememberForever(string $cacheKey, Closure $callback): mixed |
305 | 305 | { |
306 | 306 | return $this->retriever->rememberForever($cacheKey, $callback); |
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
310 | - * Returns a CacheConfig instance for configuration management. |
|
311 | - * |
|
312 | - * @return CacheConfig |
|
313 | - */ |
|
310 | + * Returns a CacheConfig instance for configuration management. |
|
311 | + * |
|
312 | + * @return CacheConfig |
|
313 | + */ |
|
314 | 314 | public function setConfig(): CacheConfig |
315 | 315 | { |
316 | 316 | return new CacheConfig($this); |
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | - * Sets the cache driver based on the configuration. |
|
321 | - * |
|
322 | - * @return CacheDriver |
|
323 | - */ |
|
320 | + * Sets the cache driver based on the configuration. |
|
321 | + * |
|
322 | + * @return CacheDriver |
|
323 | + */ |
|
324 | 324 | public function setDriver(): CacheDriver |
325 | 325 | { |
326 | 326 | return new CacheDriver($this); |
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
330 | - * Sets a message for the cache operation. |
|
331 | - * |
|
332 | - * @param string $message |
|
333 | - * @param boolean $success |
|
334 | - * @return void |
|
335 | - */ |
|
330 | + * Sets a message for the cache operation. |
|
331 | + * |
|
332 | + * @param string $message |
|
333 | + * @param boolean $success |
|
334 | + * @return void |
|
335 | + */ |
|
336 | 336 | private function setMessage(string $message, bool $success): void |
337 | 337 | { |
338 | 338 | $this->message = $message; |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | - * Retrieves the message from the last operation. |
|
344 | - * |
|
345 | - * @return string |
|
346 | - */ |
|
343 | + * Retrieves the message from the last operation. |
|
344 | + * |
|
345 | + * @return string |
|
346 | + */ |
|
347 | 347 | public function getMessage(): string |
348 | 348 | { |
349 | 349 | return $this->message; |
@@ -392,32 +392,32 @@ discard block |
||
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
395 | - * Enables or disables the formatter for cache data. |
|
396 | - * |
|
397 | - * @return void |
|
398 | - */ |
|
395 | + * Enables or disables the formatter for cache data. |
|
396 | + * |
|
397 | + * @return void |
|
398 | + */ |
|
399 | 399 | public function useFormatter(): void |
400 | 400 | { |
401 | 401 | $this->formatted = !$this->formatted; |
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
405 | - * Validates the options provided for the Cacheer instance. |
|
406 | - * |
|
407 | - * @param array $options |
|
408 | - * @return void |
|
409 | - */ |
|
405 | + * Validates the options provided for the Cacheer instance. |
|
406 | + * |
|
407 | + * @param array $options |
|
408 | + * @return void |
|
409 | + */ |
|
410 | 410 | private function validateOptions(array $options): void |
411 | 411 | { |
412 | 412 | $this->options = $options; |
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
416 | - * Enable or disable data compression |
|
417 | - * |
|
418 | - * @param bool $status |
|
419 | - * @return $this |
|
420 | - */ |
|
416 | + * Enable or disable data compression |
|
417 | + * |
|
418 | + * @param bool $status |
|
419 | + * @return $this |
|
420 | + */ |
|
421 | 421 | public function useCompression(bool $status = true): Cacheer |
422 | 422 | { |
423 | 423 | $this->compression = $status; |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
428 | - * Enable encryption for cached data |
|
429 | - * |
|
430 | - * @param string $key |
|
431 | - * @return $this |
|
432 | - */ |
|
428 | + * Enable encryption for cached data |
|
429 | + * |
|
430 | + * @param string $key |
|
431 | + * @return $this |
|
432 | + */ |
|
433 | 433 | public function useEncryption(string $key): Cacheer |
434 | 434 | { |
435 | 435 | $this->encryptionKey = $key; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore |
52 | 52 | */ |
53 | - public RedisCacheStore|DatabaseCacheStore|ArrayCacheStore|FileCacheStore $cacheStore; |
|
53 | + public RedisCacheStore | DatabaseCacheStore | ArrayCacheStore | FileCacheStore $cacheStore; |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @var array |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param int|string $ttl |
93 | 93 | * @return bool |
94 | 94 | */ |
95 | - public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool |
|
95 | + public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600): bool |
|
96 | 96 | { |
97 | 97 | return $this->mutator->add($cacheKey, $cacheData, $namespace, $ttl); |
98 | 98 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param string|int $ttl |
189 | 189 | * @return CacheDataFormatter|mixed |
190 | 190 | */ |
191 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed |
|
191 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed |
|
192 | 192 | { |
193 | 193 | return $this->retriever->getCache($cacheKey, $namespace, $ttl); |
194 | 194 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param string|int $ttl |
202 | 202 | * @return CacheDataFormatter|array |
203 | 203 | */ |
204 | - public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): CacheDataFormatter|array |
|
204 | + public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): CacheDataFormatter | array |
|
205 | 205 | { |
206 | 206 | return $this->retriever->getMany($cacheKeys, $namespace, $ttl); |
207 | 207 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param string|int $ttl |
251 | 251 | * @return void |
252 | 252 | */ |
253 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): void |
|
253 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): void |
|
254 | 254 | { |
255 | 255 | $this->mutator->putCache($cacheKey, $cacheData, $namespace, $ttl); |
256 | 256 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param string $namespace |
277 | 277 | * @return void |
278 | 278 | */ |
279 | - public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = ''): void |
|
279 | + public function renewCache(string $cacheKey, string | int $ttl = 3600, string $namespace = ''): void |
|
280 | 280 | { |
281 | 281 | $this->mutator->renewCache($cacheKey, $ttl, $namespace); |
282 | 282 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @param Closure $callback |
290 | 290 | * @return mixed |
291 | 291 | */ |
292 | - public function remember(string $cacheKey, int|string $ttl, Closure $callback): mixed |
|
292 | + public function remember(string $cacheKey, int | string $ttl, Closure $callback): mixed |
|
293 | 293 | { |
294 | 294 | return $this->retriever->remember($cacheKey, $ttl, $callback); |
295 | 295 | } |