@@ -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 |
@@ -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 |
@@ -12,20 +12,20 @@ discard block |
||
12 | 12 | class CacheRedisHelper |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @param mixed $data |
|
17 | - * @param bool $serialize |
|
18 | - * @return mixed |
|
19 | - */ |
|
20 | - public static function serialize(mixed $data, bool $serialize = true) |
|
21 | - { |
|
15 | + /** |
|
16 | + * @param mixed $data |
|
17 | + * @param bool $serialize |
|
18 | + * @return mixed |
|
19 | + */ |
|
20 | + public static function serialize(mixed $data, bool $serialize = true) |
|
21 | + { |
|
22 | 22 | if($serialize) { |
23 | - return serialize($data); |
|
23 | + return serialize($data); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | return unserialize($data); |
27 | 27 | |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param array $item |
@@ -54,63 +54,63 @@ discard block |
||
54 | 54 | return (array)$cacheData; |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * @param mixed $currentCacheData |
|
59 | - * @param mixed $cacheData |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData) |
|
63 | - { |
|
64 | - /** |
|
65 | - * Se ambos forem arrays, mescle-os de forma recursiva para preservar subarrays |
|
66 | - */ |
|
67 | - if (is_array($currentCacheData) && is_array($cacheData)) { |
|
68 | - return self::mergeRecursive($currentCacheData, $cacheData); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Se $currentCacheData não for um array, inicialize-o como um array vazio |
|
73 | - */ |
|
74 | - if (!is_array($currentCacheData)) { |
|
75 | - $currentCacheData = []; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Se $cacheData não for um array, converta-o em um array |
|
80 | - */ |
|
81 | - if (!is_array($cacheData)) { |
|
82 | - $cacheData = [$cacheData]; |
|
83 | - } |
|
84 | - |
|
85 | - return array_merge($currentCacheData, $cacheData); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Mescla arrays de forma recursiva. |
|
90 | - * @param array $array1 |
|
91 | - * @param array $array2 |
|
92 | - * @return array |
|
93 | - */ |
|
94 | - private static function mergeRecursive(array $array1, array $array2) |
|
95 | - { |
|
96 | - foreach ($array2 as $key => $value) { |
|
97 | - |
|
98 | - /** |
|
99 | - * Se a chave existe em ambos os arrays e ambos os valores são arrays, mescle recursivamente |
|
100 | - */ |
|
101 | - if (isset($array1[$key]) && is_array($array1[$key]) && is_array($value)) { |
|
102 | - $array1[$key] = self::mergeRecursive($array1[$key], $value); |
|
103 | - } else { |
|
104 | - |
|
105 | - /** |
|
106 | - * Caso contrário, sobrescreva o valor em $array1 com o valor de $array2 |
|
107 | - */ |
|
108 | - $array1[$key] = $value; |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - return $array1; |
|
113 | - } |
|
57 | + /** |
|
58 | + * @param mixed $currentCacheData |
|
59 | + * @param mixed $cacheData |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData) |
|
63 | + { |
|
64 | + /** |
|
65 | + * Se ambos forem arrays, mescle-os de forma recursiva para preservar subarrays |
|
66 | + */ |
|
67 | + if (is_array($currentCacheData) && is_array($cacheData)) { |
|
68 | + return self::mergeRecursive($currentCacheData, $cacheData); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Se $currentCacheData não for um array, inicialize-o como um array vazio |
|
73 | + */ |
|
74 | + if (!is_array($currentCacheData)) { |
|
75 | + $currentCacheData = []; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Se $cacheData não for um array, converta-o em um array |
|
80 | + */ |
|
81 | + if (!is_array($cacheData)) { |
|
82 | + $cacheData = [$cacheData]; |
|
83 | + } |
|
84 | + |
|
85 | + return array_merge($currentCacheData, $cacheData); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Mescla arrays de forma recursiva. |
|
90 | + * @param array $array1 |
|
91 | + * @param array $array2 |
|
92 | + * @return array |
|
93 | + */ |
|
94 | + private static function mergeRecursive(array $array1, array $array2) |
|
95 | + { |
|
96 | + foreach ($array2 as $key => $value) { |
|
97 | + |
|
98 | + /** |
|
99 | + * Se a chave existe em ambos os arrays e ambos os valores são arrays, mescle recursivamente |
|
100 | + */ |
|
101 | + if (isset($array1[$key]) && is_array($array1[$key]) && is_array($value)) { |
|
102 | + $array1[$key] = self::mergeRecursive($array1[$key], $value); |
|
103 | + } else { |
|
104 | + |
|
105 | + /** |
|
106 | + * Caso contrário, sobrescreva o valor em $array1 com o valor de $array2 |
|
107 | + */ |
|
108 | + $array1[$key] = $value; |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + return $array1; |
|
113 | + } |
|
114 | 114 | |
115 | 115 | } |
116 | 116 |
@@ -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 |
@@ -34,8 +34,8 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | - * @return void |
|
38 | - */ |
|
37 | + * @return void |
|
38 | + */ |
|
39 | 39 | public static function copyEnv() |
40 | 40 | { |
41 | 41 | $rootDir = self::getRootPath(); |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | { |
11 | 11 | |
12 | 12 | /** |
13 | - * @param string $dir |
|
14 | - * @return void |
|
15 | - */ |
|
13 | + * @param string $dir |
|
14 | + * @return void |
|
15 | + */ |
|
16 | 16 | public function createDirectory(string $dir) |
17 | 17 | { |
18 | 18 | if ((!file_exists($dir) || !is_dir($dir)) && !mkdir($dir, 0777, true)) { |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | - * @param string $filename |
|
25 | - * @param string $data |
|
26 | - * @return void |
|
27 | - */ |
|
24 | + * @param string $filename |
|
25 | + * @param string $data |
|
26 | + * @return void |
|
27 | + */ |
|
28 | 28 | public function writeFile(string $filename, string $data) |
29 | 29 | { |
30 | 30 | if (!@file_put_contents($filename, $data, LOCK_EX)) { |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * @param string $filename |
|
37 | - * @return string |
|
38 | - */ |
|
36 | + * @param string $filename |
|
37 | + * @return string |
|
38 | + */ |
|
39 | 39 | public function readFile(string $filename) |
40 | 40 | { |
41 | 41 | if (!$this->fileExists($filename)) { |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | - * @param string $filename |
|
49 | - * @return bool |
|
50 | - */ |
|
48 | + * @param string $filename |
|
49 | + * @return bool |
|
50 | + */ |
|
51 | 51 | public function fileExists(string $filename) |
52 | 52 | { |
53 | 53 | return file_exists($filename); |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | - * @param string $filename |
|
58 | - * @return void |
|
59 | - */ |
|
57 | + * @param string $filename |
|
58 | + * @return void |
|
59 | + */ |
|
60 | 60 | public function removeFile(string $filename) |
61 | 61 | { |
62 | 62 | if (file_exists($filename)) { |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | - * @param string $dir |
|
69 | - * @return void |
|
70 | - */ |
|
68 | + * @param string $dir |
|
69 | + * @return void |
|
70 | + */ |
|
71 | 71 | public function clearDirectory(string $dir) |
72 | 72 | { |
73 | 73 | $iterator = new RecursiveIteratorIterator( |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | - * @param mixed $data |
|
85 | - * @param bool $serealize |
|
86 | - */ |
|
84 | + * @param mixed $data |
|
85 | + * @param bool $serealize |
|
86 | + */ |
|
87 | 87 | public function serialize(mixed $data, bool $serealize = true) |
88 | 88 | { |
89 | 89 | if($serealize) { |
@@ -7,26 +7,26 @@ discard block |
||
7 | 7 | class OptionBuildTest extends TestCase |
8 | 8 | { |
9 | 9 | |
10 | - private $cache; |
|
11 | - private $cacheDir; |
|
10 | + private $cache; |
|
11 | + private $cacheDir; |
|
12 | 12 | |
13 | - protected function setUp(): void |
|
14 | - { |
|
13 | + protected function setUp(): void |
|
14 | + { |
|
15 | 15 | $this->cacheDir = __DIR__ . '/cache'; |
16 | 16 | if (!file_exists($this->cacheDir) || !is_dir($this->cacheDir)) { |
17 | - mkdir($this->cacheDir, 0755, true); |
|
17 | + mkdir($this->cacheDir, 0755, true); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | $this->cache = new Cacheer(); |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - protected function tearDown(): void |
|
24 | - { |
|
23 | + protected function tearDown(): void |
|
24 | + { |
|
25 | 25 | $this->cache->flushCache(); |
26 | - } |
|
26 | + } |
|
27 | 27 | |
28 | - public function test_it_can_set_cache_diretory() |
|
29 | - { |
|
28 | + public function test_it_can_set_cache_diretory() |
|
29 | + { |
|
30 | 30 | $cacheDir = __DIR__ . "/cache"; |
31 | 31 | |
32 | 32 | $options = OptionBuilder::forFile() |
@@ -35,23 +35,23 @@ discard block |
||
35 | 35 | |
36 | 36 | $this->assertArrayHasKey('cacheDir', $options); |
37 | 37 | $this->assertEquals($cacheDir, $options['cacheDir']); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - public function test_it_can_set_expiration_time() |
|
41 | + public function test_it_can_set_expiration_time() |
|
42 | 42 | { |
43 | 43 | |
44 | - $options = OptionBuilder::forFile() |
|
45 | - ->expirationTime('2 hours') |
|
46 | - ->build(); |
|
44 | + $options = OptionBuilder::forFile() |
|
45 | + ->expirationTime('2 hours') |
|
46 | + ->build(); |
|
47 | 47 | |
48 | - $this->assertArrayHasKey('expirationTime', $options); |
|
49 | - $this->assertEquals('2 hours', $options['expirationTime']); |
|
48 | + $this->assertArrayHasKey('expirationTime', $options); |
|
49 | + $this->assertEquals('2 hours', $options['expirationTime']); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function test_it_can_set_flush_after() |
53 | 53 | { |
54 | - $options = OptionBuilder::forFile() |
|
54 | + $options = OptionBuilder::forFile() |
|
55 | 55 | ->flushAfter('11 seconds') |
56 | 56 | ->build(); |
57 | 57 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | public function test_it_can_set_multiple_options_together() |
63 | 63 | { |
64 | - $cacheDir = __DIR__ . "/cache"; |
|
64 | + $cacheDir = __DIR__ . "/cache"; |
|
65 | 65 | |
66 | - $options = OptionBuilder::forFile() |
|
66 | + $options = OptionBuilder::forFile() |
|
67 | 67 | ->dir($cacheDir) |
68 | 68 | ->expirationTime('1 day') |
69 | 69 | ->flushAfter('30 minutes') |
@@ -76,41 +76,41 @@ discard block |
||
76 | 76 | ], $options); |
77 | 77 | } |
78 | 78 | |
79 | - public function test_it_allows_setting_expiration_time_with_timebuilder() |
|
79 | + public function test_it_allows_setting_expiration_time_with_timebuilder() |
|
80 | 80 | { |
81 | - $options = OptionBuilder::forFile()->expirationTime()->week(1)->build(); |
|
82 | - $this->assertArrayHasKey('expirationTime', $options); |
|
83 | - $this->assertEquals('1 weeks', $options['expirationTime']); |
|
81 | + $options = OptionBuilder::forFile()->expirationTime()->week(1)->build(); |
|
82 | + $this->assertArrayHasKey('expirationTime', $options); |
|
83 | + $this->assertEquals('1 weeks', $options['expirationTime']); |
|
84 | 84 | } |
85 | 85 | |
86 | - public function test_it_allows_setting_flush_after_with_timebuilder() |
|
87 | - { |
|
86 | + public function test_it_allows_setting_flush_after_with_timebuilder() |
|
87 | + { |
|
88 | 88 | $options = OptionBuilder::forFile()->flushAfter()->second(10)->build(); |
89 | 89 | $this->assertArrayHasKey('flushAfter', $options); |
90 | 90 | $this->assertEquals('10 seconds', $options['flushAfter']); |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - public function test_it_can_set_multiple_options_together_with_timebuilder() |
|
94 | - { |
|
93 | + public function test_it_can_set_multiple_options_together_with_timebuilder() |
|
94 | + { |
|
95 | 95 | $cacheDir = __DIR__ . "/cache"; |
96 | 96 | $options = OptionBuilder::forFile() |
97 | - ->dir($cacheDir) |
|
98 | - ->expirationTime()->week(1) |
|
99 | - ->flushAfter()->minute(10) |
|
100 | - ->build(); |
|
97 | + ->dir($cacheDir) |
|
98 | + ->expirationTime()->week(1) |
|
99 | + ->flushAfter()->minute(10) |
|
100 | + ->build(); |
|
101 | 101 | |
102 | 102 | $this->assertEquals([ |
103 | 103 | 'cacheDir' => $cacheDir, |
104 | 104 | 'expirationTime' => '1 weeks', |
105 | 105 | 'flushAfter' => '10 minutes', |
106 | 106 | ], $options); |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - public function test_it_returns_empty_array_when_no_options_are_set() |
|
110 | - { |
|
109 | + public function test_it_returns_empty_array_when_no_options_are_set() |
|
110 | + { |
|
111 | 111 | $options = OptionBuilder::forFile()->build(); |
112 | 112 | $this->assertIsArray($options); |
113 | 113 | $this->assertEmpty($options); |
114 | - } |
|
114 | + } |
|
115 | 115 | |
116 | 116 | } |
@@ -11,103 +11,103 @@ |
||
11 | 11 | */ |
12 | 12 | class FileOptionBuilder |
13 | 13 | { |
14 | - /** @param null|string $cacheDir */ |
|
15 | - private ?string $cacheDir = null; |
|
14 | + /** @param null|string $cacheDir */ |
|
15 | + private ?string $cacheDir = null; |
|
16 | 16 | |
17 | - /** @param null|string $expirationTime */ |
|
18 | - private ?string $expirationTime = null; |
|
17 | + /** @param null|string $expirationTime */ |
|
18 | + private ?string $expirationTime = null; |
|
19 | 19 | |
20 | - /** @param null|string $flushAfter */ |
|
21 | - private ?string $flushAfter = null; |
|
20 | + /** @param null|string $flushAfter */ |
|
21 | + private ?string $flushAfter = null; |
|
22 | 22 | |
23 | - /** @param array $options */ |
|
24 | - private array $options = []; |
|
23 | + /** @param array $options */ |
|
24 | + private array $options = []; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param string $cacheDir |
|
28 | - * @return $this |
|
29 | - */ |
|
30 | - public function dir(string $cacheDir) |
|
31 | - { |
|
26 | + /** |
|
27 | + * @param string $cacheDir |
|
28 | + * @return $this |
|
29 | + */ |
|
30 | + public function dir(string $cacheDir) |
|
31 | + { |
|
32 | 32 | $this->cacheDir = $cacheDir; |
33 | 33 | return $this; |
34 | - } |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param ?string $expirationTime |
|
38 | - * @return $this|TimeBuilder |
|
39 | - */ |
|
40 | - public function expirationTime(?string $expirationTime = null) |
|
41 | - { |
|
36 | + /** |
|
37 | + * @param ?string $expirationTime |
|
38 | + * @return $this|TimeBuilder |
|
39 | + */ |
|
40 | + public function expirationTime(?string $expirationTime = null) |
|
41 | + { |
|
42 | 42 | |
43 | 43 | if (!is_null($expirationTime)) { |
44 | - $this->expirationTime = $expirationTime; |
|
45 | - return $this; |
|
44 | + $this->expirationTime = $expirationTime; |
|
45 | + return $this; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return new TimeBuilder(function ($formattedTime){ |
49 | - $this->expirationTime = $formattedTime; |
|
49 | + $this->expirationTime = $formattedTime; |
|
50 | 50 | }, $this); |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param ?string $flushAfter |
|
55 | - * @return $this|TimeBuilder |
|
56 | - */ |
|
57 | - public function flushAfter(?string $flushAfter = null) |
|
58 | - { |
|
53 | + /** |
|
54 | + * @param ?string $flushAfter |
|
55 | + * @return $this|TimeBuilder |
|
56 | + */ |
|
57 | + public function flushAfter(?string $flushAfter = null) |
|
58 | + { |
|
59 | 59 | |
60 | 60 | if (!is_null($flushAfter)) { |
61 | - $this->flushAfter = mb_strtolower($flushAfter, 'UTF-8'); |
|
62 | - return $this; |
|
61 | + $this->flushAfter = mb_strtolower($flushAfter, 'UTF-8'); |
|
62 | + return $this; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return new TimeBuilder(function ($formattedTime){ |
66 | - $this->flushAfter = $formattedTime; |
|
66 | + $this->flushAfter = $formattedTime; |
|
67 | 67 | }, $this); |
68 | - } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return array |
|
72 | - */ |
|
73 | - public function build() |
|
74 | - { |
|
70 | + /** |
|
71 | + * @return array |
|
72 | + */ |
|
73 | + public function build() |
|
74 | + { |
|
75 | 75 | return $this->validated(); |
76 | - } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - private function validated() |
|
82 | - { |
|
78 | + /** |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + private function validated() |
|
82 | + { |
|
83 | 83 | foreach ($this->properties() as $key => $value) { |
84 | 84 | if ($this->isValidAndNotNull($value)) { |
85 | 85 | $this->options[$key] = $value; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | return $this->options; |
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param mixed $data |
|
93 | - * @return bool |
|
94 | - */ |
|
95 | - private function isValidAndNotNull(mixed $data) |
|
96 | - { |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @param mixed $data |
|
93 | + * @return bool |
|
94 | + */ |
|
95 | + private function isValidAndNotNull(mixed $data) |
|
96 | + { |
|
97 | 97 | return !empty($data) ? true : false; |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return array |
|
102 | - */ |
|
103 | - private function properties() |
|
104 | - { |
|
100 | + /** |
|
101 | + * @return array |
|
102 | + */ |
|
103 | + private function properties() |
|
104 | + { |
|
105 | 105 | $properties = [ |
106 | - 'cacheDir' => $this->cacheDir, |
|
107 | - 'expirationTime' => $this->expirationTime, |
|
108 | - 'flushAfter' => $this->flushAfter |
|
106 | + 'cacheDir' => $this->cacheDir, |
|
107 | + 'expirationTime' => $this->expirationTime, |
|
108 | + 'flushAfter' => $this->flushAfter |
|
109 | 109 | ]; |
110 | 110 | |
111 | 111 | return $properties; |
112 | - } |
|
112 | + } |
|
113 | 113 | } |
@@ -14,38 +14,38 @@ |
||
14 | 14 | class RedisCacheManager |
15 | 15 | { |
16 | 16 | |
17 | - /** @var Predis\Client */ |
|
18 | - private static $redis; |
|
17 | + /** @var Predis\Client */ |
|
18 | + private static $redis; |
|
19 | 19 | |
20 | - /** @param string $namespace */ |
|
21 | - private static $namespace; |
|
20 | + /** @param string $namespace */ |
|
21 | + private static $namespace; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return Client |
|
25 | - */ |
|
26 | - public static function connect() |
|
27 | - { |
|
23 | + /** |
|
24 | + * @return Client |
|
25 | + */ |
|
26 | + public static function connect() |
|
27 | + { |
|
28 | 28 | Autoloader::register(); |
29 | 29 | self::$redis = new Client([ |
30 | - 'scheme' => 'tcp', |
|
31 | - 'host' => REDIS_CONNECTION_CONFIG['REDIS_HOST'], |
|
32 | - 'port' => REDIS_CONNECTION_CONFIG['REDIS_PORT'], |
|
33 | - 'password' => REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'], |
|
34 | - 'database' => 0 |
|
30 | + 'scheme' => 'tcp', |
|
31 | + 'host' => REDIS_CONNECTION_CONFIG['REDIS_HOST'], |
|
32 | + 'port' => REDIS_CONNECTION_CONFIG['REDIS_PORT'], |
|
33 | + 'password' => REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'], |
|
34 | + 'database' => 0 |
|
35 | 35 | ]); |
36 | 36 | self::auth(); |
37 | 37 | self::$namespace = REDIS_CONNECTION_CONFIG['REDIS_NAMESPACE'] ?? 'Cache'; |
38 | 38 | return self::$redis; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - private static function auth() |
|
45 | - { |
|
41 | + /** |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + private static function auth() |
|
45 | + { |
|
46 | 46 | if(is_string(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']) && REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'] !== '') { |
47 | - self::$redis->auth(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']); |
|
47 | + self::$redis->auth(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']); |
|
48 | + } |
|
48 | 49 | } |
49 | - } |
|
50 | 50 | |
51 | 51 | } |