@@ -46,13 +46,13 @@ |
||
| 46 | 46 | private string $lastFlushTimeFile; |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * @var CacheLogger |
|
| 50 | - */ |
|
| 49 | + * @var CacheLogger |
|
| 50 | + */ |
|
| 51 | 51 | private $logger = null; |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * @var FileCacheManager |
|
| 55 | - */ |
|
| 54 | + * @var FileCacheManager |
|
| 55 | + */ |
|
| 56 | 56 | private FileCacheManager $fileManager; |
| 57 | 57 | |
| 58 | 58 | public function __construct(array $options = []) |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param string|int $ttl |
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600) |
|
| 75 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600) |
|
| 76 | 76 | { |
| 77 | 77 | |
| 78 | 78 | $ttl = CacheFileHelper::ttl($ttl, $this->defaultTTL); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param string|int $ttl |
| 97 | 97 | * @return void |
| 98 | 98 | */ |
| 99 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600) |
|
| 99 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600) |
|
| 100 | 100 | { |
| 101 | 101 | $cacheFile = $this->buildCacheFilePath($cacheKey, $namespace); |
| 102 | 102 | $data = $this->fileManager->serialize($cacheData); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param string $namespace |
| 172 | 172 | * @return void |
| 173 | 173 | */ |
| 174 | - public function renewCache(string $cacheKey, string|int $ttl, string $namespace = '') |
|
| 174 | + public function renewCache(string $cacheKey, string | int $ttl, string $namespace = '') |
|
| 175 | 175 | { |
| 176 | 176 | $cacheData = $this->getCache($cacheKey, $namespace); |
| 177 | 177 | if ($cacheData) { |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | { |
| 279 | 279 | $flushAfterSeconds = CacheFileHelper::convertExpirationToSeconds($flushAfter); |
| 280 | 280 | |
| 281 | - if(!$this->fileManager->fileExists($this->lastFlushTimeFile)) { |
|
| 281 | + if (!$this->fileManager->fileExists($this->lastFlushTimeFile)) { |
|
| 282 | 282 | $this->fileManager->writeFile($this->lastFlushTimeFile, time()); |
| 283 | 283 | return; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $lastFlushTime = (int) $this->fileManager->readFile($this->lastFlushTimeFile); |
|
| 286 | + $lastFlushTime = (int)$this->fileManager->readFile($this->lastFlushTimeFile); |
|
| 287 | 287 | |
| 288 | 288 | if ((time() - $lastFlushTime) >= $flushAfterSeconds) { |
| 289 | 289 | $this->flushCache(); |
@@ -13,8 +13,8 @@ |
||
| 13 | 13 | class MigrationManager |
| 14 | 14 | { |
| 15 | 15 | /** |
| 16 | - * @return void |
|
| 17 | - */ |
|
| 16 | + * @return void |
|
| 17 | + */ |
|
| 18 | 18 | public static function migrate(PDO $connection) |
| 19 | 19 | { |
| 20 | 20 | $driver = $connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
| 19 | 19 | { |
| 20 | - return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
|
| 20 | + return new self(self::getBefore() . ": " . $message, $code, $previous, $details); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -8,34 +8,34 @@ |
||
| 8 | 8 | { |
| 9 | 9 | |
| 10 | 10 | |
| 11 | - /** @param string $before */ |
|
| 12 | - private static string $before = "<Redis Cache Store Exception>"; |
|
| 11 | + /** @param string $before */ |
|
| 12 | + private static string $before = "<Redis Cache Store Exception>"; |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @return void |
|
| 17 | - */ |
|
| 18 | - public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 19 | - { |
|
| 15 | + /** |
|
| 16 | + * @return void |
|
| 17 | + */ |
|
| 18 | + public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 19 | + { |
|
| 20 | 20 | return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public static function getBefore() |
|
| 28 | - { |
|
| 24 | + /** |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public static function getBefore() |
|
| 28 | + { |
|
| 29 | 29 | return self::$before; |
| 30 | - } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @return void |
|
| 34 | - */ |
|
| 35 | - public static function setBefore(string $text) |
|
| 36 | - { |
|
| 32 | + /** |
|
| 33 | + * @return void |
|
| 34 | + */ |
|
| 35 | + public static function setBefore(string $text) |
|
| 36 | + { |
|
| 37 | 37 | self::$before = $text; |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -7,32 +7,32 @@ |
||
| 7 | 7 | class CacheDatabaseException extends BaseException |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @param string $before */ |
|
| 11 | - private static string $before = "<Database Cache Store Exception>"; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * @return void |
|
| 15 | - */ |
|
| 16 | - public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 17 | - { |
|
| 10 | + /** @param string $before */ |
|
| 11 | + private static string $before = "<Database Cache Store Exception>"; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * @return void |
|
| 15 | + */ |
|
| 16 | + public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 17 | + { |
|
| 18 | 18 | return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @return string |
|
| 24 | - */ |
|
| 25 | - public static function getBefore() |
|
| 26 | - { |
|
| 22 | + /** |
|
| 23 | + * @return string |
|
| 24 | + */ |
|
| 25 | + public static function getBefore() |
|
| 26 | + { |
|
| 27 | 27 | return self::$before; |
| 28 | - } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @return void |
|
| 32 | - */ |
|
| 33 | - public static function setBefore(string $text) |
|
| 34 | - { |
|
| 30 | + /** |
|
| 31 | + * @return void |
|
| 32 | + */ |
|
| 33 | + public static function setBefore(string $text) |
|
| 34 | + { |
|
| 35 | 35 | self::$before = $text; |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
| 19 | 19 | { |
| 20 | - return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
|
| 20 | + return new self(self::getBefore() . ": " . $message, $code, $previous, $details); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -7,31 +7,31 @@ |
||
| 7 | 7 | class ConnectionException extends BaseException |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @param string $before */ |
|
| 11 | - private static string $before = "<Connection Exception>"; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * @return void |
|
| 15 | - */ |
|
| 16 | - public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 17 | - { |
|
| 10 | + /** @param string $before */ |
|
| 11 | + private static string $before = "<Connection Exception>"; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * @return void |
|
| 15 | + */ |
|
| 16 | + public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 17 | + { |
|
| 18 | 18 | return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @return string |
|
| 23 | - */ |
|
| 24 | - public static function getBefore() |
|
| 25 | - { |
|
| 21 | + /** |
|
| 22 | + * @return string |
|
| 23 | + */ |
|
| 24 | + public static function getBefore() |
|
| 25 | + { |
|
| 26 | 26 | return self::$before; |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @return void |
|
| 31 | - */ |
|
| 32 | - public static function setBefore(string $text) |
|
| 33 | - { |
|
| 29 | + /** |
|
| 30 | + * @return void |
|
| 31 | + */ |
|
| 32 | + public static function setBefore(string $text) |
|
| 33 | + { |
|
| 34 | 34 | self::$before = $text; |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
| 17 | 17 | { |
| 18 | - return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
|
| 18 | + return new self(self::getBefore() . ": " . $message, $code, $previous, $details); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -7,33 +7,33 @@ |
||
| 7 | 7 | class CacheFileException extends BaseException |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @param string $before */ |
|
| 11 | - private static string $before = "<File Cache Store Exception>"; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * @return void |
|
| 15 | - */ |
|
| 16 | - public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 17 | - { |
|
| 10 | + /** @param string $before */ |
|
| 11 | + private static string $before = "<File Cache Store Exception>"; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * @return void |
|
| 15 | + */ |
|
| 16 | + public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 17 | + { |
|
| 18 | 18 | return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @return string |
|
| 24 | - */ |
|
| 25 | - public static function getBefore() |
|
| 26 | - { |
|
| 22 | + /** |
|
| 23 | + * @return string |
|
| 24 | + */ |
|
| 25 | + public static function getBefore() |
|
| 26 | + { |
|
| 27 | 27 | return self::$before; |
| 28 | - } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @return void |
|
| 32 | - */ |
|
| 33 | - public static function setBefore(string $text) |
|
| 34 | - { |
|
| 30 | + /** |
|
| 31 | + * @return void |
|
| 32 | + */ |
|
| 33 | + public static function setBefore(string $text) |
|
| 34 | + { |
|
| 35 | 35 | self::$before = $text; |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
| 19 | 19 | { |
| 20 | - return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
|
| 20 | + return new self(self::getBefore() . ": " . $message, $code, $previous, $details); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * @param string $cacheKey |
|
| 52 | - * @param string $namespace |
|
| 53 | - * @return mixed |
|
| 54 | - */ |
|
| 51 | + * @param string $cacheKey |
|
| 52 | + * @param string $namespace |
|
| 53 | + * @return mixed |
|
| 54 | + */ |
|
| 55 | 55 | public function retrieve(string $cacheKey, string $namespace = '') |
| 56 | 56 | { |
| 57 | 57 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | - * @param string $cacheKey |
|
| 109 | - * @param string|int $ttl |
|
| 110 | - * @param string $namespace |
|
| 111 | - * @return bool |
|
| 112 | - */ |
|
| 108 | + * @param string $cacheKey |
|
| 109 | + * @param string|int $ttl |
|
| 110 | + * @param string $namespace |
|
| 111 | + * @return bool |
|
| 112 | + */ |
|
| 113 | 113 | public function renew(string $cacheKey, string|int $ttl, string $namespace = '') |
| 114 | 114 | { |
| 115 | 115 | $currentTime = date('Y-m-d H:i:s'); |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | - * @param string $driver |
|
| 167 | - * @return string |
|
| 168 | - */ |
|
| 166 | + * @param string $driver |
|
| 167 | + * @return string |
|
| 168 | + */ |
|
| 169 | 169 | private function getCurrentDateTime(string $driver) |
| 170 | 170 | { |
| 171 | 171 | return ($driver === 'sqlite') ? "DATETIME('now', 'localtime')" : "NOW()"; |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | * @param string|int $ttl |
| 30 | 30 | * @return bool |
| 31 | 31 | */ |
| 32 | - public function store(string $cacheKey, mixed $cacheData, string $namespace, string|int $ttl = 3600) |
|
| 32 | + public function store(string $cacheKey, mixed $cacheData, string $namespace, string | int $ttl = 3600) |
|
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - if(!empty($this->retrieve($cacheKey, $namespace))) { |
|
| 35 | + if (!empty($this->retrieve($cacheKey, $namespace))) { |
|
| 36 | 36 | $this->update($cacheKey, $cacheData, $namespace); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string $namespace |
| 116 | 116 | * @return bool |
| 117 | 117 | */ |
| 118 | - public function renew(string $cacheKey, string|int $ttl, string $namespace = '') |
|
| 118 | + public function renew(string $cacheKey, string | int $ttl, string $namespace = '') |
|
| 119 | 119 | { |
| 120 | 120 | $currentTime = date('Y-m-d H:i:s'); |
| 121 | 121 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | SET expirationTime = DATE_ADD(expirationTime, INTERVAL ? SECOND) |
| 136 | 136 | WHERE cacheKey = ? AND cacheNamespace = ? AND expirationTime > ?" |
| 137 | 137 | ); |
| 138 | - $stmt->bindValue(1, (int) $ttl, PDO::PARAM_INT); |
|
| 138 | + $stmt->bindValue(1, (int)$ttl, PDO::PARAM_INT); |
|
| 139 | 139 | $stmt->bindValue(2, $cacheKey); |
| 140 | 140 | $stmt->bindValue(3, $namespace); |
| 141 | 141 | $stmt->bindValue(4, $currentTime); |
@@ -23,15 +23,15 @@ |
||
| 23 | 23 | echo "Cache Found: "; |
| 24 | 24 | print_r($Cacheer->getCache($cacheKey)); |
| 25 | 25 | } else { |
| 26 | - echo $Cacheer->getMessage(); |
|
| 26 | + echo $Cacheer->getMessage(); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Renovando os dados do cache |
| 30 | 30 | $Cacheer->renewCache($cacheKey, 3600); |
| 31 | 31 | |
| 32 | 32 | if($Cacheer->isSuccess()){ |
| 33 | - echo $Cacheer->getMessage() . PHP_EOL; |
|
| 33 | + echo $Cacheer->getMessage() . PHP_EOL; |
|
| 34 | 34 | } else { |
| 35 | - echo $Cacheer->getMessage() . PHP_EOL; |
|
| 35 | + echo $Cacheer->getMessage() . PHP_EOL; |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | $Cacheer->putCache($cacheKey, $userProfile, ttl: 300); |
| 20 | 20 | |
| 21 | 21 | // Recuperando dados do cache |
| 22 | -if($Cacheer->isSuccess()){ |
|
| 22 | +if ($Cacheer->isSuccess()) { |
|
| 23 | 23 | echo "Cache Found: "; |
| 24 | 24 | print_r($Cacheer->getCache($cacheKey)); |
| 25 | 25 | } else { |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | // Renovando os dados do cache |
| 30 | 30 | $Cacheer->renewCache($cacheKey, 3600); |
| 31 | 31 | |
| 32 | -if($Cacheer->isSuccess()){ |
|
| 32 | +if ($Cacheer->isSuccess()) { |
|
| 33 | 33 | echo $Cacheer->getMessage() . PHP_EOL; |
| 34 | 34 | } else { |
| 35 | 35 | echo $Cacheer->getMessage() . PHP_EOL; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | echo "Cache Found: "; |
| 30 | 30 | print_r($Cacheer->getCache($cacheKey)); |
| 31 | 31 | } else { |
| 32 | - echo $Cacheer->getMessage(); |
|
| 32 | + echo $Cacheer->getMessage(); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -40,6 +40,6 @@ discard block |
||
| 40 | 40 | echo $Cacheer->getMessage() . PHP_EOL; |
| 41 | 41 | print_r($Cacheer->getCache($cacheKey)); |
| 42 | 42 | } else { |
| 43 | - echo $Cacheer->getMessage(); |
|
| 43 | + echo $Cacheer->getMessage(); |
|
| 44 | 44 | } |
| 45 | 45 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $Cacheer->putCache($cacheKey, $userProfile); |
| 26 | 26 | |
| 27 | 27 | // Recuperando dados do cache |
| 28 | -if($Cacheer->isSuccess()){ |
|
| 28 | +if ($Cacheer->isSuccess()) { |
|
| 29 | 29 | echo "Cache Found: "; |
| 30 | 30 | print_r($Cacheer->getCache($cacheKey)); |
| 31 | 31 | } else { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | // Mesclando os dados |
| 37 | 37 | $Cacheer->appendCache($cacheKey, $userProfile02); |
| 38 | 38 | |
| 39 | -if($Cacheer->isSuccess()){ |
|
| 39 | +if ($Cacheer->isSuccess()) { |
|
| 40 | 40 | echo $Cacheer->getMessage() . PHP_EOL; |
| 41 | 41 | print_r($Cacheer->getCache($cacheKey)); |
| 42 | 42 | } else { |