@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $this->cache->flushCache(); |
| 260 | 260 | |
| 261 | - $value = $this->cache->remember('remember_test_key', 60, function () { |
|
| 261 | + $value = $this->cache->remember('remember_test_key', 60, function() { |
|
| 262 | 262 | return 'valor_teste'; |
| 263 | 263 | }); |
| 264 | 264 | |
| 265 | 265 | $this->assertEquals('valor_teste', $value); |
| 266 | 266 | |
| 267 | - $cachedValue = $this->cache->remember('remember_test_key', 60, function (){ |
|
| 267 | + $cachedValue = $this->cache->remember('remember_test_key', 60, function() { |
|
| 268 | 268 | return 'novo_valor'; |
| 269 | 269 | }); |
| 270 | 270 | |
@@ -276,12 +276,12 @@ discard block |
||
| 276 | 276 | { |
| 277 | 277 | $this->cache->flushCache(); |
| 278 | 278 | |
| 279 | - $value = $this->cache->rememberForever('remember_forever_key', function () { |
|
| 279 | + $value = $this->cache->rememberForever('remember_forever_key', function() { |
|
| 280 | 280 | return 'valor_eterno'; |
| 281 | 281 | }); |
| 282 | 282 | $this->assertEquals('valor_eterno', $value); |
| 283 | 283 | |
| 284 | - $cachedValue = $this->cache->rememberForever('remember_forever_key', function () { |
|
| 284 | + $cachedValue = $this->cache->rememberForever('remember_forever_key', function() { |
|
| 285 | 285 | return 'novo_valor'; |
| 286 | 286 | }); |
| 287 | 287 | |
@@ -7,27 +7,27 @@ discard block |
||
| 7 | 7 | class RedisTest extends TestCase |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @var Cacheer */ |
|
| 11 | - private $cache; |
|
| 10 | + /** @var Cacheer */ |
|
| 11 | + private $cache; |
|
| 12 | 12 | |
| 13 | - protected function setUp(): void |
|
| 14 | - { |
|
| 13 | + protected function setUp(): void |
|
| 14 | + { |
|
| 15 | 15 | $this->cache = new Cacheer(); |
| 16 | 16 | $this->cache->setDriver()->useRedisDriver(); |
| 17 | - } |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - protected function tearDown(): void |
|
| 20 | - { |
|
| 19 | + protected function tearDown(): void |
|
| 20 | + { |
|
| 21 | 21 | $this->cache->flushCache(); |
| 22 | - } |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function testUsingRedisDriverSetsProperInstance() |
|
| 25 | - { |
|
| 24 | + public function testUsingRedisDriverSetsProperInstance() |
|
| 25 | + { |
|
| 26 | 26 | $this->assertInstanceOf(RedisCacheStore::class, $this->cache->cacheStore); |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function testPutCacheInRedis() |
|
| 30 | - { |
|
| 29 | + public function testPutCacheInRedis() |
|
| 30 | + { |
|
| 31 | 31 | $cacheKey = 'test_key'; |
| 32 | 32 | $cacheData = ['name' => 'Sílvio Silva', 'role' => 'Developer']; |
| 33 | 33 | |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | $this->assertNotEmpty($this->cache->getCache($cacheKey)); |
| 38 | 38 | $this->assertEquals($cacheData, $this->cache->getCache($cacheKey)); |
| 39 | 39 | |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function testGetCacheFromRedis() |
|
| 43 | - { |
|
| 42 | + public function testGetCacheFromRedis() |
|
| 43 | + { |
|
| 44 | 44 | $cacheKey = 'test_key'; |
| 45 | 45 | $cacheData = ['name' => 'Sílvio Silva', 'role' => 'Developer']; |
| 46 | 46 | |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | $data = $this->cache->getCache($cacheKey); |
| 52 | 52 | $this->assertNotEmpty($data); |
| 53 | 53 | $this->assertEquals($cacheData, $data); |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - public function testExpiredCacheInRedis() |
|
| 57 | - { |
|
| 56 | + public function testExpiredCacheInRedis() |
|
| 57 | + { |
|
| 58 | 58 | $cacheKey = 'expired_key'; |
| 59 | 59 | $cacheData = ['name' => 'Expired User', 'email' => '[email protected]']; |
| 60 | 60 | |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | $this->assertEquals("Cache stored successfully", $this->cache->getMessage()); |
| 65 | 65 | $this->assertEmpty($this->cache->getCache($cacheKey)); |
| 66 | 66 | $this->assertFalse($this->cache->isSuccess()); |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public function testOverwriteExistingCacheInRedis() |
|
| 70 | - { |
|
| 69 | + public function testOverwriteExistingCacheInRedis() |
|
| 70 | + { |
|
| 71 | 71 | $cacheKey = 'overwrite_key'; |
| 72 | 72 | $initialCacheData = ['name' => 'Initial Data', 'email' => '[email protected]']; |
| 73 | 73 | $newCacheData = ['name' => 'New Data', 'email' => '[email protected]']; |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | $this->cache->appendCache($cacheKey, $newCacheData); |
| 79 | 79 | $this->assertEquals("Cache appended successfully", $this->cache->getMessage()); |
| 80 | 80 | $this->assertEquals($newCacheData, $this->cache->getCache($cacheKey)); |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - public function testPutManyCacheItemsInRedis() |
|
| 84 | - { |
|
| 85 | - $items = [ |
|
| 83 | + public function testPutManyCacheItemsInRedis() |
|
| 84 | + { |
|
| 85 | + $items = [ |
|
| 86 | 86 | [ |
| 87 | 87 | 'cacheKey' => 'user_1_profile', |
| 88 | 88 | 'cacheData' => [ |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | foreach ($items as $item) { |
| 108 | 108 | $this->assertEquals($item['cacheData'], $this->cache->getCache($item['cacheKey'])); |
| 109 | 109 | } |
| 110 | - } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - public function testAppendCacheWithNamespaceInRedis() |
|
| 112 | + public function testAppendCacheWithNamespaceInRedis() |
|
| 113 | 113 | { |
| 114 | 114 | $cacheKey = 'test_append_key_ns'; |
| 115 | 115 | $namespace = 'test_namespace'; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $this->assertEquals($expectedData, $cachedData); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - public function testDataOutputShouldBeOfTypeArray() |
|
| 135 | + public function testDataOutputShouldBeOfTypeArray() |
|
| 136 | 136 | { |
| 137 | 137 | |
| 138 | 138 | $this->cache->useFormatter(); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $this->assertJson($cacheOutput); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function testClearCacheDataFromRedis() |
|
| 181 | + public function testClearCacheDataFromRedis() |
|
| 182 | 182 | { |
| 183 | 183 | $cacheKey = 'test_key'; |
| 184 | 184 | $data = 'test_data'; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $this->assertEmpty($this->cache->getCache($cacheKey)); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - public function testFlushCacheDataFromDatabase() |
|
| 196 | + public function testFlushCacheDataFromDatabase() |
|
| 197 | 197 | { |
| 198 | 198 | $key1 = 'test_key1'; |
| 199 | 199 | $data1 = 'test_data1'; |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | $this->assertEquals("Cache flushed successfully", $this->cache->getMessage()); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - public function testHasCacheFromRedis() |
|
| 216 | - { |
|
| 215 | + public function testHasCacheFromRedis() |
|
| 216 | + { |
|
| 217 | 217 | $cacheKey = 'test_key'; |
| 218 | 218 | $cacheData = ['name' => 'Sílvio Silva', 'role' => 'Developer']; |
| 219 | 219 | |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | $this->assertEquals("Cache stored successfully", $this->cache->getMessage()); |
| 223 | 223 | $this->assertTrue($this->cache->isSuccess()); |
| 224 | - } |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - public function testRenewCacheFromRedis() |
|
| 227 | - { |
|
| 226 | + public function testRenewCacheFromRedis() |
|
| 227 | + { |
|
| 228 | 228 | $cacheKey = 'expired_key'; |
| 229 | 229 | $cacheData = ['name' => 'Expired User', 'email' => '[email protected]']; |
| 230 | 230 | |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | $this->cache->renewCache($cacheKey, 7200); |
| 240 | 240 | $this->assertTrue($this->cache->isSuccess()); |
| 241 | 241 | $this->assertNotEmpty($this->cache->getCache($cacheKey)); |
| 242 | - } |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | 244 | public function testRenewCacheWithNamespaceFromRedis() |
| 245 | - { |
|
| 245 | + { |
|
| 246 | 246 | $cacheKey = 'expired_key'; |
| 247 | 247 | $namespace = 'expired_namespace'; |
| 248 | 248 | $cacheData = ['name' => 'Expired User', 'email' => '[email protected]']; |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | $this->cache->renewCache($cacheKey, 7200, $namespace); |
| 257 | 257 | $this->assertTrue($this->cache->isSuccess()); |
| 258 | 258 | $this->assertNotEmpty($this->cache->getCache($cacheKey, $namespace)); |
| 259 | - } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - public function test_remember_saves_and_recover_values() |
|
| 261 | + public function test_remember_saves_and_recover_values() |
|
| 262 | 262 | { |
| 263 | 263 | $this->cache->flushCache(); |
| 264 | 264 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | |
| 296 | - public function test_get_and_forget() |
|
| 296 | + public function test_get_and_forget() |
|
| 297 | 297 | { |
| 298 | 298 | $cacheKey = 'cache_key_test'; |
| 299 | 299 | $this->cache->putCache($cacheKey, 10); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $this->assertNull($noCacheData); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - public function test_store_if_not_present_with_add_function() |
|
| 317 | + public function test_store_if_not_present_with_add_function() |
|
| 318 | 318 | { |
| 319 | 319 | $existentKey = 'cache_key_test'; |
| 320 | 320 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - public function test_increment_function() { |
|
| 341 | + public function test_increment_function() { |
|
| 342 | 342 | |
| 343 | 343 | $cacheKey = 'test_increment'; |
| 344 | 344 | $cacheData = 2025; |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $this->cache->flushCache(); |
| 260 | 260 | |
| 261 | - $value = $this->cache->remember('remember_test_key', 60, function () { |
|
| 261 | + $value = $this->cache->remember('remember_test_key', 60, function() { |
|
| 262 | 262 | return 'valor_teste'; |
| 263 | 263 | }); |
| 264 | 264 | |
| 265 | 265 | $this->assertEquals('valor_teste', $value); |
| 266 | 266 | |
| 267 | - $cachedValue = $this->cache->remember('remember_test_key', 60, function (){ |
|
| 267 | + $cachedValue = $this->cache->remember('remember_test_key', 60, function() { |
|
| 268 | 268 | return 'novo_valor'; |
| 269 | 269 | }); |
| 270 | 270 | |
@@ -276,12 +276,12 @@ discard block |
||
| 276 | 276 | { |
| 277 | 277 | $this->cache->flushCache(); |
| 278 | 278 | |
| 279 | - $value = $this->cache->rememberForever('remember_forever_key', function () { |
|
| 279 | + $value = $this->cache->rememberForever('remember_forever_key', function() { |
|
| 280 | 280 | return 'valor_eterno'; |
| 281 | 281 | }); |
| 282 | 282 | $this->assertEquals('valor_eterno', $value); |
| 283 | 283 | |
| 284 | - $cachedValue = $this->cache->rememberForever('remember_forever_key', function () { |
|
| 284 | + $cachedValue = $this->cache->rememberForever('remember_forever_key', function() { |
|
| 285 | 285 | return 'novo_valor'; |
| 286 | 286 | }); |
| 287 | 287 | |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | public function test_remember_saves_and_recover_values() |
| 234 | 234 | { |
| 235 | - $value = $this->cache->remember('remember_test_key', 60, function () { |
|
| 235 | + $value = $this->cache->remember('remember_test_key', 60, function() { |
|
| 236 | 236 | return 'valor_teste'; |
| 237 | 237 | }); |
| 238 | 238 | |
| 239 | 239 | $this->assertEquals('valor_teste', $value); |
| 240 | 240 | |
| 241 | - $cachedValue = $this->cache->remember('remember_test_key', 60, function (){ |
|
| 241 | + $cachedValue = $this->cache->remember('remember_test_key', 60, function() { |
|
| 242 | 242 | return 'novo_valor'; |
| 243 | 243 | }); |
| 244 | 244 | |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | public function test_remember_forever_saves_value_indefinitely() |
| 250 | 250 | { |
| 251 | 251 | |
| 252 | - $value = $this->cache->rememberForever('remember_forever_key', function () { |
|
| 252 | + $value = $this->cache->rememberForever('remember_forever_key', function() { |
|
| 253 | 253 | return 'valor_eterno'; |
| 254 | 254 | }); |
| 255 | 255 | $this->assertEquals('valor_eterno', $value); |
| 256 | 256 | |
| 257 | - $cachedValue = $this->cache->rememberForever('remember_forever_key', function () { |
|
| 257 | + $cachedValue = $this->cache->rememberForever('remember_forever_key', function() { |
|
| 258 | 258 | return 'novo_valor'; |
| 259 | 259 | }); |
| 260 | 260 | |
@@ -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(); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param string|int $ttl |
| 56 | 56 | * @return CacheDataFormatter|mixed |
| 57 | 57 | */ |
| 58 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600) |
|
| 58 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600) |
|
| 59 | 59 | { |
| 60 | 60 | $cacheData = $this->cacheStore->getCache($cacheKey, $namespace, $ttl); |
| 61 | 61 | $this->setMessage($this->cacheStore->getMessage(), $this->cacheStore->isSuccess()); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param string|int $ttl |
| 70 | 70 | * @return void |
| 71 | 71 | */ |
| 72 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600) |
|
| 72 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600) |
|
| 73 | 73 | { |
| 74 | 74 | $this->cacheStore->putCache($cacheKey, $cacheData, $namespace, $ttl); |
| 75 | 75 | $this->setMessage($this->cacheStore->getMessage(), $this->cacheStore->isSuccess()); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string $namespace |
| 116 | 116 | * @return mixed |
| 117 | 117 | */ |
| 118 | - public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = '') |
|
| 118 | + public function renewCache(string $cacheKey, string | int $ttl = 3600, string $namespace = '') |
|
| 119 | 119 | { |
| 120 | 120 | $renewedCache = $this->cacheStore->renewCache($cacheKey, $ttl, $namespace); |
| 121 | 121 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $cacheData = $this->getCache($cacheKey, $namespace); |
| 140 | 140 | |
| 141 | - if(!empty($cacheData) && is_numeric($cacheData)) { |
|
| 141 | + if (!empty($cacheData) && is_numeric($cacheData)) { |
|
| 142 | 142 | $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace); |
| 143 | 143 | $this->setMessage($this->getMessage(), $this->isSuccess()); |
| 144 | 144 | return true; |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | * @param Closure $callback |
| 175 | 175 | * @return mixed |
| 176 | 176 | */ |
| 177 | - public function remember(string $cacheKey, int|string $ttl, Closure $callback) |
|
| 177 | + public function remember(string $cacheKey, int | string $ttl, Closure $callback) |
|
| 178 | 178 | { |
| 179 | 179 | $isCache = $this->getCache($cacheKey); |
| 180 | 180 | |
| 181 | 181 | |
| 182 | - if(!empty($isCache)) { |
|
| 182 | + if (!empty($isCache)) { |
|
| 183 | 183 | return $this->getCache($cacheKey, ttl: $ttl); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * @param int|string $ttl |
| 225 | 225 | * @return bool |
| 226 | 226 | */ |
| 227 | - public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600) |
|
| 227 | + public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600) |
|
| 228 | 228 | { |
| 229 | 229 | if (!empty($this->getCache($cacheKey, $namespace))) { |
| 230 | 230 | return true; |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * @param string $cacheKey |
|
| 133 | - * @param int $amount |
|
| 134 | - * @param string $namespace |
|
| 135 | - * @return bool |
|
| 136 | - */ |
|
| 132 | + * @param string $cacheKey |
|
| 133 | + * @param int $amount |
|
| 134 | + * @param string $namespace |
|
| 135 | + * @return bool |
|
| 136 | + */ |
|
| 137 | 137 | public function increment(string $cacheKey, int $amount = 1, string $namespace = '') |
| 138 | 138 | { |
| 139 | 139 | $cacheData = $this->getCache($cacheKey, $namespace); |
@@ -148,20 +148,20 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * @param string $cacheKey |
|
| 152 | - * @param int $amount |
|
| 153 | - * @param string $namespace |
|
| 154 | - * @return bool |
|
| 155 | - */ |
|
| 151 | + * @param string $cacheKey |
|
| 152 | + * @param int $amount |
|
| 153 | + * @param string $namespace |
|
| 154 | + * @return bool |
|
| 155 | + */ |
|
| 156 | 156 | public function decrement(string $cacheKey, int $amount = 1, string $namespace = '') |
| 157 | 157 | { |
| 158 | - return $this->increment($cacheKey, ($amount * -1), $namespace); |
|
| 158 | + return $this->increment($cacheKey, ($amount * -1), $namespace); |
|
| 159 | 159 | } |
| 160 | 160 | /** |
| 161 | - * @param string $cacheKey |
|
| 162 | - * @param mixed $cacheData |
|
| 163 | - * @return void |
|
| 164 | - */ |
|
| 161 | + * @param string $cacheKey |
|
| 162 | + * @param mixed $cacheData |
|
| 163 | + * @return void |
|
| 164 | + */ |
|
| 165 | 165 | public function forever(string $cacheKey, mixed $cacheData) |
| 166 | 166 | { |
| 167 | 167 | $this->putCache($cacheKey, $cacheData, '', 31536000 * 1000); |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | - * @param string $cacheKey |
|
| 173 | - * @param int|string $ttl |
|
| 174 | - * @param Closure $callback |
|
| 175 | - * @return mixed |
|
| 176 | - */ |
|
| 172 | + * @param string $cacheKey |
|
| 173 | + * @param int|string $ttl |
|
| 174 | + * @param Closure $callback |
|
| 175 | + * @return mixed |
|
| 176 | + */ |
|
| 177 | 177 | public function remember(string $cacheKey, int|string $ttl, Closure $callback) |
| 178 | 178 | { |
| 179 | 179 | $isCache = $this->getCache($cacheKey); |
@@ -191,20 +191,20 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | - * @param string $cacheKey |
|
| 195 | - * @param Closure $callback |
|
| 196 | - * @return mixed |
|
| 197 | - */ |
|
| 194 | + * @param string $cacheKey |
|
| 195 | + * @param Closure $callback |
|
| 196 | + * @return mixed |
|
| 197 | + */ |
|
| 198 | 198 | public function rememberForever(string $cacheKey, Closure $callback) |
| 199 | 199 | { |
| 200 | 200 | return $this->remember($cacheKey, 31536000 * 1000, $callback); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * @param string $cacheKey |
|
| 205 | - * @param string $namespace |
|
| 206 | - * @return mixed |
|
| 207 | - */ |
|
| 204 | + * @param string $cacheKey |
|
| 205 | + * @param string $namespace |
|
| 206 | + * @return mixed |
|
| 207 | + */ |
|
| 208 | 208 | public function getAndForget(string $cacheKey, string $namespace = '') |
| 209 | 209 | { |
| 210 | 210 | $cachedData = $this->getCache($cacheKey, $namespace); |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | - * @param string $cacheKey |
|
| 222 | - * @param mixed $cacheData |
|
| 223 | - * @param string $namespace |
|
| 224 | - * @param int|string $ttl |
|
| 225 | - * @return bool |
|
| 226 | - */ |
|
| 221 | + * @param string $cacheKey |
|
| 222 | + * @param mixed $cacheData |
|
| 223 | + * @param string $namespace |
|
| 224 | + * @param int|string $ttl |
|
| 225 | + * @return bool |
|
| 226 | + */ |
|
| 227 | 227 | public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600) |
| 228 | 228 | { |
| 229 | 229 | if (!empty($this->getCache($cacheKey, $namespace))) { |
@@ -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); |