@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param string|int $ttl |
| 133 | 133 | * @return mixed |
| 134 | 134 | */ |
| 135 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed |
|
| 135 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed |
|
| 136 | 136 | { |
| 137 | 137 | $fullCacheKey = $this->buildKey($cacheKey, $namespace); |
| 138 | 138 | $cacheData = $this->redis->get($fullCacheKey); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @param string|int $ttl |
| 188 | 188 | * @return array |
| 189 | 189 | */ |
| 190 | - public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array |
|
| 190 | + public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array |
|
| 191 | 191 | { |
| 192 | 192 | $results = []; |
| 193 | 193 | foreach ($cacheKeys as $cacheKey) { |
@@ -285,12 +285,12 @@ discard block |
||
| 285 | 285 | * @param string|int|null $ttl |
| 286 | 286 | * @return Status|null |
| 287 | 287 | */ |
| 288 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int|null $ttl = null): ?Status |
|
| 288 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int | null $ttl = null): ?Status |
|
| 289 | 289 | { |
| 290 | 290 | $cacheFullKey = $this->buildKey($cacheKey, $namespace); |
| 291 | 291 | $serializedData = CacheRedisHelper::serialize($cacheData); |
| 292 | 292 | |
| 293 | - $result = $ttl ? $this->redis->setex($cacheFullKey, (int) $ttl, $serializedData) |
|
| 293 | + $result = $ttl ? $this->redis->setex($cacheFullKey, (int)$ttl, $serializedData) |
|
| 294 | 294 | : $this->redis->set($cacheFullKey, $serializedData); |
| 295 | 295 | |
| 296 | 296 | if ($result) { |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * @return void |
| 333 | 333 | * @throws CacheRedisException |
| 334 | 334 | */ |
| 335 | - public function renewCache(string $cacheKey, string|int $ttl, string $namespace = ''): void |
|
| 335 | + public function renewCache(string $cacheKey, string | int $ttl, string $namespace = ''): void |
|
| 336 | 336 | { |
| 337 | 337 | $cacheFullKey = $this->buildKey($cacheKey, $namespace); |
| 338 | 338 | $dump = $this->getDump($cacheFullKey); |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @return bool |
| 364 | 364 | * @throws CacheRedisException |
| 365 | 365 | */ |
| 366 | - private function restoreKey(string $fullKey, string|int $ttl, mixed $dump): bool |
|
| 366 | + private function restoreKey(string $fullKey, string | int $ttl, mixed $dump): bool |
|
| 367 | 367 | { |
| 368 | 368 | try { |
| 369 | 369 | $this->redis->restore($fullKey, $ttl * 1000, $dump, 'REPLACE'); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @return mixed |
| 190 | 190 | * @throws CacheFileException return string|void |
| 191 | 191 | */ |
| 192 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed |
|
| 192 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed |
|
| 193 | 193 | { |
| 194 | 194 | |
| 195 | 195 | $ttl = CacheFileHelper::ttl($ttl, $this->defaultTTL); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @return array |
| 278 | 278 | * @throws CacheFileException |
| 279 | 279 | */ |
| 280 | - public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array |
|
| 280 | + public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array |
|
| 281 | 281 | { |
| 282 | 282 | $ttl = CacheFileHelper::ttl($ttl, $this->defaultTTL); |
| 283 | 283 | $results = []; |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @return void |
| 325 | 325 | * @throws CacheFileException |
| 326 | 326 | */ |
| 327 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): void |
|
| 327 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): void |
|
| 328 | 328 | { |
| 329 | 329 | $cacheFile = $this->buildCacheFilePath($cacheKey, $namespace); |
| 330 | 330 | $data = $this->fileManager->serialize($cacheData); |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @return void |
| 364 | 364 | * @throws CacheFileException |
| 365 | 365 | */ |
| 366 | - public function renewCache(string $cacheKey, string|int $ttl, string $namespace = ''): void |
|
| 366 | + public function renewCache(string $cacheKey, string | int $ttl, string $namespace = ''): void |
|
| 367 | 367 | { |
| 368 | 368 | $cacheData = $this->getCache($cacheKey, $namespace); |
| 369 | 369 | if ($cacheData) { |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param int|string $ttl |
| 141 | 141 | * @return mixed |
| 142 | 142 | */ |
| 143 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed |
|
| 143 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed |
|
| 144 | 144 | { |
| 145 | 145 | $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace); |
| 146 | 146 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param string|int $ttl |
| 230 | 230 | * @return array |
| 231 | 231 | */ |
| 232 | - public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array |
|
| 232 | + public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array |
|
| 233 | 233 | { |
| 234 | 234 | $results = []; |
| 235 | 235 | foreach ($cacheKeys as $cacheKey) { |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | { |
| 264 | 264 | $cacheData = $this->getCache($cacheKey, $namespace); |
| 265 | 265 | |
| 266 | - if(!empty($cacheData) && is_numeric($cacheData)) { |
|
| 266 | + if (!empty($cacheData) && is_numeric($cacheData)) { |
|
| 267 | 267 | $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace); |
| 268 | 268 | $this->setMessage($this->getMessage(), $this->isSuccess()); |
| 269 | 269 | return true; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param int|string $ttl |
| 302 | 302 | * @return bool |
| 303 | 303 | */ |
| 304 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool |
|
| 304 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600): bool |
|
| 305 | 305 | { |
| 306 | 306 | $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace); |
| 307 | 307 | |
@@ -344,12 +344,12 @@ discard block |
||
| 344 | 344 | * @param string $namespace |
| 345 | 345 | * @return void |
| 346 | 346 | */ |
| 347 | - public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = ''): void |
|
| 347 | + public function renewCache(string $cacheKey, int | string $ttl = 3600, string $namespace = ''): void |
|
| 348 | 348 | { |
| 349 | 349 | $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace); |
| 350 | 350 | |
| 351 | 351 | if (isset($this->arrayStore[$arrayStoreKey])) { |
| 352 | - $ttlSeconds = is_numeric($ttl) ? (int) $ttl : strtotime($ttl) - time(); |
|
| 352 | + $ttlSeconds = is_numeric($ttl) ? (int)$ttl : strtotime($ttl) - time(); |
|
| 353 | 353 | $this->arrayStore[$arrayStoreKey]['expirationTime'] = time() + $ttlSeconds; |
| 354 | 354 | $this->setMessage("cacheKey: {$cacheKey} renewed successfully", true); |
| 355 | 355 | $this->logger->debug("{$this->getMessage()} from array driver."); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function clearCache(string $cacheKey, string $namespace = ''): void |
| 78 | 78 | { |
| 79 | 79 | $data = $this->cacheRepository->clear($cacheKey, $namespace); |
| 80 | - if($data) { |
|
| 80 | + if ($data) { |
|
| 81 | 81 | $this->setMessage("Cache deleted successfully!", true); |
| 82 | 82 | } else { |
| 83 | 83 | $this->setMessage("Cache does not exists!", false); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function flushCache(): void |
| 95 | 95 | { |
| 96 | - if($this->cacheRepository->flush()){ |
|
| 96 | + if ($this->cacheRepository->flush()) { |
|
| 97 | 97 | $this->setMessage("Flush finished successfully", true); |
| 98 | 98 | } else { |
| 99 | 99 | $this->setMessage("Something went wrong. Please, try again.", false); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string|int $ttl |
| 112 | 112 | * @return mixed |
| 113 | 113 | */ |
| 114 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed |
|
| 114 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed |
|
| 115 | 115 | { |
| 116 | 116 | $cacheData = $this->retrieveCache($cacheKey, $namespace); |
| 117 | 117 | if ($cacheData) { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @param string|int $ttl |
| 152 | 152 | * @return array |
| 153 | 153 | */ |
| 154 | - public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array |
|
| 154 | + public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array |
|
| 155 | 155 | { |
| 156 | 156 | $cacheData = []; |
| 157 | 157 | foreach ($cacheKeys as $cacheKey) { |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | * @param string|int $ttl |
| 235 | 235 | * @return bool |
| 236 | 236 | */ |
| 237 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): bool |
|
| 237 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): bool |
|
| 238 | 238 | { |
| 239 | - if($this->storeCache($cacheKey, $cacheData, $namespace, $ttl)){ |
|
| 239 | + if ($this->storeCache($cacheKey, $cacheData, $namespace, $ttl)) { |
|
| 240 | 240 | $this->logger->debug("{$this->getMessage()} from database driver."); |
| 241 | 241 | return true; |
| 242 | 242 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | private function processBatchItems(array $batchItems, string $namespace): void |
| 273 | 273 | { |
| 274 | - foreach($batchItems as $item) { |
|
| 274 | + foreach ($batchItems as $item) { |
|
| 275 | 275 | CacheDatabaseHelper::validateCacheItem($item); |
| 276 | 276 | $cacheKey = $item['cacheKey']; |
| 277 | 277 | $cacheData = $item['cacheData']; |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @param string $namespace |
| 289 | 289 | * @return bool |
| 290 | 290 | */ |
| 291 | - private function renew(string $cacheKey, string|int $ttl = 3600, string $namespace = ''): bool |
|
| 291 | + private function renew(string $cacheKey, string | int $ttl = 3600, string $namespace = ''): bool |
|
| 292 | 292 | { |
| 293 | 293 | $cacheData = $this->getCache($cacheKey, $namespace); |
| 294 | 294 | if ($cacheData) { |
@@ -336,10 +336,10 @@ discard block |
||
| 336 | 336 | * @param string|int $ttl |
| 337 | 337 | * @return bool |
| 338 | 338 | */ |
| 339 | - private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): bool |
|
| 339 | + private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): bool |
|
| 340 | 340 | { |
| 341 | 341 | $data = $this->cacheRepository->store($cacheKey, $cacheData, $namespace, $ttl); |
| 342 | - if($data) { |
|
| 342 | + if ($data) { |
|
| 343 | 343 | $this->setMessage("Cache Stored Successfully", true); |
| 344 | 344 | return true; |
| 345 | 345 | } |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | private function updateCache(string $cacheKey, mixed $cacheData, string $namespace = ''): bool |
| 359 | 359 | { |
| 360 | 360 | $data = $this->cacheRepository->update($cacheKey, $cacheData, $namespace); |
| 361 | - if($data) { |
|
| 361 | + if ($data) { |
|
| 362 | 362 | $this->setMessage("Cache updated successfully.", true); |
| 363 | 363 | return true; |
| 364 | 364 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @return string|bool |
| 45 | 45 | * @throws CacheFileException |
| 46 | 46 | */ |
| 47 | - public function readFile(string $filename): string|bool |
|
| 47 | + public function readFile(string $filename): string | bool |
|
| 48 | 48 | { |
| 49 | 49 | if (!$this->fileExists($filename)) { |
| 50 | 50 | throw CacheFileException::create("File not found: {$filename}"); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function serialize(mixed $data, bool $serialize = true): mixed |
| 97 | 97 | { |
| 98 | - if($serialize) { |
|
| 98 | + if ($serialize) { |
|
| 99 | 99 | return serialize($data); |
| 100 | 100 | } |
| 101 | 101 | return unserialize($data); |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | private static function auth(): void |
| 49 | 49 | { |
| 50 | - if(is_string(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']) && REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'] !== '') { |
|
| 50 | + if (is_string(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']) && REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'] !== '') { |
|
| 51 | 51 | self::$redis->auth(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']); |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -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); |
@@ -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 | |
@@ -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(); |