@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function flushCache(): void |
34 | 34 | { |
35 | 35 | ($this->flushCallback)(); |
36 | - @file_put_contents($this->lastFlushTimeFile, (string) time()); |
|
36 | + @file_put_contents($this->lastFlushTimeFile, (string)time()); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | if (!isset($options['flushAfter'])) { |
47 | 47 | return; |
48 | 48 | } |
49 | - $this->scheduleFlush((string) $options['flushAfter']); |
|
49 | + $this->scheduleFlush((string)$options['flushAfter']); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | */ |
56 | 56 | private function scheduleFlush(string $flushAfter): void |
57 | 57 | { |
58 | - $flushAfterSeconds = (int) CacheFileHelper::convertExpirationToSeconds($flushAfter); |
|
58 | + $flushAfterSeconds = (int)CacheFileHelper::convertExpirationToSeconds($flushAfter); |
|
59 | 59 | |
60 | 60 | if (!file_exists($this->lastFlushTimeFile)) { |
61 | - @file_put_contents($this->lastFlushTimeFile, (string) time()); |
|
61 | + @file_put_contents($this->lastFlushTimeFile, (string)time()); |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - $lastFlushTime = (int) @file_get_contents($this->lastFlushTimeFile); |
|
65 | + $lastFlushTime = (int)@file_get_contents($this->lastFlushTimeFile); |
|
66 | 66 | |
67 | 67 | if ((time() - $lastFlushTime) >= $flushAfterSeconds) { |
68 | 68 | $this->flushCache(); |
69 | - @file_put_contents($this->lastFlushTimeFile, (string) time()); |
|
69 | + @file_put_contents($this->lastFlushTimeFile, (string)time()); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | |
62 | 62 | // OptionBuilder support |
63 | 63 | if (!empty($options['namespace'])) { |
64 | - $this->namespace = (string) $options['namespace']; |
|
64 | + $this->namespace = (string)$options['namespace']; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // Default TTL from options |
68 | 68 | if (!empty($options['expirationTime'])) { |
69 | - $this->defaultTTL = (int) CacheFileHelper::convertExpirationToSeconds((string) $options['expirationTime']); |
|
69 | + $this->defaultTTL = (int)CacheFileHelper::convertExpirationToSeconds((string)$options['expirationTime']); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // Auto-flush support |
73 | 73 | $lastFlushFile = FlushHelper::pathFor('redis', $this->namespace ?: 'default'); |
74 | - $this->flusher = new GenericFlusher($lastFlushFile, function () { |
|
74 | + $this->flusher = new GenericFlusher($lastFlushFile, function() { |
|
75 | 75 | $this->flushCache(); |
76 | 76 | }); |
77 | 77 | $this->flusher->handleAutoFlush($options); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string|int $ttl |
160 | 160 | * @return mixed |
161 | 161 | */ |
162 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed |
|
162 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed |
|
163 | 163 | { |
164 | 164 | $fullCacheKey = $this->buildKey($cacheKey, $namespace); |
165 | 165 | $cacheData = $this->redis->get($fullCacheKey); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param string|int $ttl |
215 | 215 | * @return array |
216 | 216 | */ |
217 | - public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array |
|
217 | + public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array |
|
218 | 218 | { |
219 | 219 | $results = []; |
220 | 220 | foreach ($cacheKeys as $cacheKey) { |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param string|int|null $ttl |
315 | 315 | * @return Status|null |
316 | 316 | */ |
317 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int|null $ttl = null): ?Status |
|
317 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int | null $ttl = null): ?Status |
|
318 | 318 | { |
319 | 319 | $cacheFullKey = $this->buildKey($cacheKey, $namespace); |
320 | 320 | $serializedData = CacheRedisHelper::serialize($cacheData); |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | $ttlToUse = $this->defaultTTL; |
326 | 326 | } |
327 | 327 | if (is_string($ttlToUse)) { |
328 | - $ttlToUse = (int) CacheFileHelper::convertExpirationToSeconds($ttlToUse); |
|
328 | + $ttlToUse = (int)CacheFileHelper::convertExpirationToSeconds($ttlToUse); |
|
329 | 329 | } |
330 | 330 | |
331 | - $result = $ttlToUse ? $this->redis->setex($cacheFullKey, (int) $ttlToUse, $serializedData) |
|
331 | + $result = $ttlToUse ? $this->redis->setex($cacheFullKey, (int)$ttlToUse, $serializedData) |
|
332 | 332 | : $this->redis->set($cacheFullKey, $serializedData); |
333 | 333 | |
334 | 334 | if ($result) { |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * @return void |
371 | 371 | * @throws CacheRedisException |
372 | 372 | */ |
373 | - public function renewCache(string $cacheKey, string|int $ttl, string $namespace = ''): void |
|
373 | + public function renewCache(string $cacheKey, string | int $ttl, string $namespace = ''): void |
|
374 | 374 | { |
375 | 375 | $cacheFullKey = $this->buildKey($cacheKey, $namespace); |
376 | 376 | $dump = $this->getDump($cacheFullKey); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return bool |
402 | 402 | * @throws CacheRedisException |
403 | 403 | */ |
404 | - private function restoreKey(string $fullKey, string|int $ttl, mixed $dump): bool |
|
404 | + private function restoreKey(string $fullKey, string | int $ttl, mixed $dump): bool |
|
405 | 405 | { |
406 | 406 | try { |
407 | 407 | $this->redis->restore($fullKey, $ttl * 1000, $dump, 'REPLACE'); |
@@ -12,24 +12,24 @@ discard block |
||
12 | 12 | class TimeBuilder |
13 | 13 | { |
14 | 14 | |
15 | - /** @param Closure $callback */ |
|
16 | - private Closure $callback; |
|
15 | + /** @param Closure $callback */ |
|
16 | + private Closure $callback; |
|
17 | 17 | |
18 | - /** @var mixed */ |
|
19 | - private $builder = null; |
|
18 | + /** @var mixed */ |
|
19 | + private $builder = null; |
|
20 | 20 | |
21 | - /** |
|
22 | - * TimeBuilder constructor. |
|
23 | - * @param Closure $callback |
|
24 | - * @param mixed $builder |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function __construct(Closure $callback, $builder) |
|
29 | - { |
|
21 | + /** |
|
22 | + * TimeBuilder constructor. |
|
23 | + * @param Closure $callback |
|
24 | + * @param mixed $builder |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function __construct(Closure $callback, $builder) |
|
29 | + { |
|
30 | 30 | $this->callback = $callback; |
31 | 31 | $this->builder = $builder; |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Sets the time in seconds. |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | * @param int $seconds |
38 | 38 | * @return mixed |
39 | 39 | */ |
40 | - public function second(int $seconds) |
|
41 | - { |
|
40 | + public function second(int $seconds) |
|
41 | + { |
|
42 | 42 | return $this->setTime($seconds, "seconds"); |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Sets the time in minutes. |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @param int $minutes |
49 | 49 | * @return mixed |
50 | 50 | */ |
51 | - public function minute(int $minutes) |
|
52 | - { |
|
51 | + public function minute(int $minutes) |
|
52 | + { |
|
53 | 53 | return $this->setTime($minutes, "minutes"); |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Sets the time in hours. |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * @param int $hours |
60 | 60 | * @return mixed |
61 | 61 | */ |
62 | - public function hour(int $hours) |
|
63 | - { |
|
62 | + public function hour(int $hours) |
|
63 | + { |
|
64 | 64 | return $this->setTime($hours, "hours"); |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Sets the time in days. |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param int $days |
71 | 71 | * @return mixed |
72 | 72 | */ |
73 | - public function day(int $days) |
|
74 | - { |
|
73 | + public function day(int $days) |
|
74 | + { |
|
75 | 75 | return $this->setTime($days, "days"); |
76 | - } |
|
76 | + } |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Sets the time in weeks. |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * @param int $weeks |
82 | 82 | * @return mixed |
83 | 83 | */ |
84 | - public function week(int $weeks) |
|
85 | - { |
|
84 | + public function week(int $weeks) |
|
85 | + { |
|
86 | 86 | return $this->setTime($weeks, "weeks"); |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * Sets the time in months. |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * @param int $months |
93 | 93 | * @return mixed |
94 | 94 | */ |
95 | - public function month(int $months) |
|
96 | - { |
|
95 | + public function month(int $months) |
|
96 | + { |
|
97 | 97 | return $this->setTime($months, "months"); |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | 101 | /** |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | * @param string $unit |
106 | 106 | * @return mixed |
107 | 107 | */ |
108 | - private function setTime(int $value, string $unit) |
|
109 | - { |
|
110 | - ($this->callback)("{$value} {$unit}"); |
|
108 | + private function setTime(int $value, string $unit) |
|
109 | + { |
|
110 | + ($this->callback)("{$value} {$unit}"); |
|
111 | 111 | return $this->builder; |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | } |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | - * Retrieves cache data from the database. |
|
68 | - * |
|
69 | - * @param string $cacheKey |
|
70 | - * @param string $namespace |
|
71 | - * @return mixed |
|
67 | + * Retrieves cache data from the database. |
|
68 | + * |
|
69 | + * @param string $cacheKey |
|
70 | + * @param string $namespace |
|
71 | + * @return mixed |
|
72 | 72 | */ |
73 | 73 | public function retrieve(string $cacheKey, string $namespace = ''): mixed |
74 | 74 | { |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | - * Get Update query based on the database driver. |
|
117 | - * |
|
118 | - * @return string |
|
119 | - */ |
|
116 | + * Get Update query based on the database driver. |
|
117 | + * |
|
118 | + * @return string |
|
119 | + */ |
|
120 | 120 | private function getUpdateQueryWithDriver(): string |
121 | 121 | { |
122 | 122 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | - * Get Delete query based on the database driver. |
|
131 | - * |
|
132 | - * @return string |
|
133 | - */ |
|
130 | + * Get Delete query based on the database driver. |
|
131 | + * |
|
132 | + * @return string |
|
133 | + */ |
|
134 | 134 | private function getDeleteQueryWithDriver(): string |
135 | 135 | { |
136 | 136 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | - * Updates an existing cache item in the database. |
|
145 | - * |
|
146 | - * @param string $cacheKey |
|
147 | - * @param mixed $cacheData |
|
148 | - * @param string $namespace |
|
149 | - * @return bool |
|
150 | - */ |
|
144 | + * Updates an existing cache item in the database. |
|
145 | + * |
|
146 | + * @param string $cacheKey |
|
147 | + * @param mixed $cacheData |
|
148 | + * @param string $namespace |
|
149 | + * @return bool |
|
150 | + */ |
|
151 | 151 | public function update(string $cacheKey, mixed $cacheData, string $namespace = ''): bool |
152 | 152 | { |
153 | 153 | $query = $this->getUpdateQueryWithDriver(); |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
164 | - * Clears a specific cache item from the database. |
|
165 | - * |
|
166 | - * @param string $cacheKey |
|
167 | - * @param string $namespace |
|
168 | - * @return bool |
|
169 | - */ |
|
164 | + * Clears a specific cache item from the database. |
|
165 | + * |
|
166 | + * @param string $cacheKey |
|
167 | + * @param string $namespace |
|
168 | + * @return bool |
|
169 | + */ |
|
170 | 170 | public function clear(string $cacheKey, string $namespace = ''): bool |
171 | 171 | { |
172 | 172 | $query = $this->getDeleteQueryWithDriver(); |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
182 | - * Gets the query to renew the expiration time of a cache item based on the database driver. |
|
183 | - * |
|
184 | - * @return string |
|
185 | - */ |
|
182 | + * Gets the query to renew the expiration time of a cache item based on the database driver. |
|
183 | + * |
|
184 | + * @return string |
|
185 | + */ |
|
186 | 186 | private function getRenewExpirationQueryWithDriver(): string |
187 | 187 | { |
188 | 188 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
200 | - * Checks if a cache item is valid based on its key, namespace, and current time. |
|
201 | - * |
|
202 | - * @param string $cacheKey |
|
203 | - * @param string $namespace |
|
204 | - * @param string $currentTime |
|
205 | - * @return bool |
|
206 | - */ |
|
200 | + * Checks if a cache item is valid based on its key, namespace, and current time. |
|
201 | + * |
|
202 | + * @param string $cacheKey |
|
203 | + * @param string $namespace |
|
204 | + * @param string $currentTime |
|
205 | + * @return bool |
|
206 | + */ |
|
207 | 207 | private function hasValidCache(string $cacheKey, string $namespace, string $currentTime): bool |
208 | 208 | { |
209 | 209 | $stmt = $this->connection->prepare( |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | - * Renews the expiration time of a cache item. |
|
223 | - * |
|
224 | - * @param string $cacheKey |
|
225 | - * @param string|int $ttl |
|
226 | - * @param string $namespace |
|
227 | - * @return bool |
|
228 | - */ |
|
222 | + * Renews the expiration time of a cache item. |
|
223 | + * |
|
224 | + * @param string $cacheKey |
|
225 | + * @param string|int $ttl |
|
226 | + * @param string $namespace |
|
227 | + * @return bool |
|
228 | + */ |
|
229 | 229 | public function renew(string $cacheKey, string|int $ttl, string $namespace = ''): bool |
230 | 230 | { |
231 | 231 | $currentTime = date('Y-m-d H:i:s'); |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
248 | - * Flushes all cache items from the database. |
|
249 | - * |
|
250 | - * @return bool |
|
251 | - */ |
|
248 | + * Flushes all cache items from the database. |
|
249 | + * |
|
250 | + * @return bool |
|
251 | + */ |
|
252 | 252 | public function flush(): bool |
253 | 253 | { |
254 | 254 | return $this->connection->exec("DELETE FROM {$this->table}") !== false; |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
270 | - * Gets the current date and time based on the database driver. |
|
271 | - * |
|
272 | - * @param string $driver |
|
273 | - * @return string |
|
274 | - */ |
|
270 | + * Gets the current date and time based on the database driver. |
|
271 | + * |
|
272 | + * @param string $driver |
|
273 | + * @return string |
|
274 | + */ |
|
275 | 275 | private function getCurrentDateTime(string $driver): string |
276 | 276 | { |
277 | 277 | return ($driver === 'sqlite') ? "DATETIME('now', 'localtime')" : "NOW()"; |
@@ -7,26 +7,26 @@ discard block |
||
7 | 7 | |
8 | 8 | class MigrationManagerDynamicTableTest extends TestCase |
9 | 9 | { |
10 | - private ?PDO $pdo = null; |
|
11 | - private string $table; |
|
10 | + private ?PDO $pdo = null; |
|
11 | + private string $table; |
|
12 | 12 | |
13 | - protected function setUp(): void |
|
14 | - { |
|
13 | + protected function setUp(): void |
|
14 | + { |
|
15 | 15 | $this->pdo = Connect::getInstance(); |
16 | 16 | $this->table = uniqid('mm_custom_table_'); |
17 | 17 | // Ensure clean start |
18 | 18 | $this->pdo->exec("DROP TABLE IF EXISTS {$this->table}"); |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | - protected function tearDown(): void |
|
22 | - { |
|
21 | + protected function tearDown(): void |
|
22 | + { |
|
23 | 23 | if ($this->pdo) { |
24 | - $this->pdo->exec("DROP TABLE IF EXISTS {$this->table}"); |
|
24 | + $this->pdo->exec("DROP TABLE IF EXISTS {$this->table}"); |
|
25 | + } |
|
25 | 26 | } |
26 | - } |
|
27 | 27 | |
28 | - public function test_migrate_creates_custom_table() |
|
29 | - { |
|
28 | + public function test_migrate_creates_custom_table() |
|
29 | + { |
|
30 | 30 | MigrationManager::migrate($this->pdo, $this->table); |
31 | 31 | |
32 | 32 | // Verify table exists (SQLite check) |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | $stmt->execute(); |
51 | 51 | $row = $stmt->fetch(PDO::FETCH_ASSOC); |
52 | 52 | $this->assertEquals(['a' => 1], unserialize($row['cacheData'])); |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - public function test_default_constant_table_exists() |
|
56 | - { |
|
55 | + public function test_default_constant_table_exists() |
|
56 | + { |
|
57 | 57 | // With boot autoload, the default CACHEER_TABLE should be created via Connect::getInstance() |
58 | 58 | $stmt = $this->pdo->query("SELECT name FROM sqlite_master WHERE type='table' AND name = 'cacheer_table'"); |
59 | 59 | $row = $stmt->fetch(PDO::FETCH_ASSOC); |
60 | 60 | $this->assertNotFalse($row); |
61 | - } |
|
61 | + } |
|
62 | 62 | } |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | MigrationManager::migrate($pdo, $table); |
63 | 63 | |
64 | 64 | if (!empty($options['expirationTime'])) { |
65 | - $this->defaultTTL = (int) CacheFileHelper::convertExpirationToSeconds((string) $options['expirationTime']); |
|
65 | + $this->defaultTTL = (int)CacheFileHelper::convertExpirationToSeconds((string)$options['expirationTime']); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $lastFlushFile = FlushHelper::pathFor('db', $table); |
69 | - $this->flusher = new GenericFlusher($lastFlushFile, function () { |
|
69 | + $this->flusher = new GenericFlusher($lastFlushFile, function() { |
|
70 | 70 | $this->flushCache(); |
71 | 71 | }); |
72 | 72 | $this->flusher->handleAutoFlush($options); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | public function clearCache(string $cacheKey, string $namespace = ''): void |
105 | 105 | { |
106 | 106 | $data = $this->cacheRepository->clear($cacheKey, $namespace); |
107 | - if($data) { |
|
107 | + if ($data) { |
|
108 | 108 | $this->setMessage("Cache deleted successfully!", true); |
109 | 109 | } else { |
110 | 110 | $this->setMessage("Cache does not exists!", false); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function flushCache(): void |
122 | 122 | { |
123 | - if($this->cacheRepository->flush()){ |
|
123 | + if ($this->cacheRepository->flush()) { |
|
124 | 124 | $this->setMessage("Flush finished successfully", true); |
125 | 125 | } else { |
126 | 126 | $this->setMessage("Something went wrong. Please, try again.", false); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param string|int $ttl |
139 | 139 | * @return mixed |
140 | 140 | */ |
141 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed |
|
141 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed |
|
142 | 142 | { |
143 | 143 | $cacheData = $this->retrieveCache($cacheKey, $namespace); |
144 | 144 | if ($cacheData) { |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param string|int $ttl |
179 | 179 | * @return array |
180 | 180 | */ |
181 | - public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array |
|
181 | + public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array |
|
182 | 182 | { |
183 | 183 | $cacheData = []; |
184 | 184 | foreach ($cacheKeys as $cacheKey) { |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | * @param string|int $ttl |
269 | 269 | * @return bool |
270 | 270 | */ |
271 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): bool |
|
271 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): bool |
|
272 | 272 | { |
273 | 273 | $ttlToUse = $ttl; |
274 | 274 | if ($this->defaultTTL !== null && ($ttl === null || (int)$ttl === 3600)) { |
275 | 275 | $ttlToUse = $this->defaultTTL; |
276 | 276 | } |
277 | 277 | if (is_string($ttlToUse)) { |
278 | - $ttlToUse = (int) CacheFileHelper::convertExpirationToSeconds($ttlToUse); |
|
278 | + $ttlToUse = (int)CacheFileHelper::convertExpirationToSeconds($ttlToUse); |
|
279 | 279 | } |
280 | 280 | |
281 | - if($this->storeCache($cacheKey, $cacheData, $namespace, $ttlToUse)){ |
|
281 | + if ($this->storeCache($cacheKey, $cacheData, $namespace, $ttlToUse)) { |
|
282 | 282 | $this->logger->debug("{$this->getMessage()} from database driver."); |
283 | 283 | return true; |
284 | 284 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | private function processBatchItems(array $batchItems, string $namespace): void |
315 | 315 | { |
316 | - foreach($batchItems as $item) { |
|
316 | + foreach ($batchItems as $item) { |
|
317 | 317 | CacheDatabaseHelper::validateCacheItem($item); |
318 | 318 | $cacheKey = $item['cacheKey']; |
319 | 319 | $cacheData = $item['cacheData']; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @param string $namespace |
331 | 331 | * @return bool |
332 | 332 | */ |
333 | - private function renew(string $cacheKey, string|int $ttl = 3600, string $namespace = ''): bool |
|
333 | + private function renew(string $cacheKey, string | int $ttl = 3600, string $namespace = ''): bool |
|
334 | 334 | { |
335 | 335 | $cacheData = $this->getCache($cacheKey, $namespace); |
336 | 336 | if ($cacheData) { |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | * @param string|int $ttl |
379 | 379 | * @return bool |
380 | 380 | */ |
381 | - private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): bool |
|
381 | + private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): bool |
|
382 | 382 | { |
383 | 383 | $data = $this->cacheRepository->store($cacheKey, $cacheData, $namespace, $ttl); |
384 | - if($data) { |
|
384 | + if ($data) { |
|
385 | 385 | $this->setMessage("Cache Stored Successfully", true); |
386 | 386 | return true; |
387 | 387 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | private function updateCache(string $cacheKey, mixed $cacheData, string $namespace = ''): bool |
401 | 401 | { |
402 | 402 | $data = $this->cacheRepository->update($cacheKey, $cacheData, $namespace); |
403 | - if($data) { |
|
403 | + if ($data) { |
|
404 | 404 | $this->setMessage("Cache updated successfully.", true); |
405 | 405 | return true; |
406 | 406 | } |