@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\cache; |
14 | 14 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function getCacheKey(string $name): string |
83 | 83 | { |
84 | - return $this->options['prefix'] . $name; |
|
84 | + return $this->options['prefix'].$name; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | |
143 | 143 | $time = time(); |
144 | 144 | |
145 | - while ($time + 5 > time() && $this->has($name . '_lock')) { |
|
145 | + while ($time + 5 > time() && $this->has($name.'_lock')) { |
|
146 | 146 | // 存在锁定则等待 |
147 | 147 | usleep(200000); |
148 | 148 | } |
149 | 149 | |
150 | 150 | try { |
151 | 151 | // 锁定 |
152 | - $this->set($name . '_lock', true); |
|
152 | + $this->set($name.'_lock', true); |
|
153 | 153 | |
154 | 154 | if ($value instanceof \Closure) { |
155 | 155 | // 获取缓存数据 |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | $this->set($name, $value, $expire); |
161 | 161 | |
162 | 162 | // 解锁 |
163 | - $this->delete($name . '_lock'); |
|
163 | + $this->delete($name.'_lock'); |
|
164 | 164 | } catch (\Exception | \throwable $e) { |
165 | - $this->delete($name . '_lock'); |
|
165 | + $this->delete($name.'_lock'); |
|
166 | 166 | throw $e; |
167 | 167 | } |
168 | 168 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $key = implode('-', $name); |
182 | 182 | |
183 | 183 | if (!isset($this->tag[$key])) { |
184 | - $name = array_map(function ($val) { |
|
184 | + $name = array_map(function($val) { |
|
185 | 185 | return $this->getTagKey($val); |
186 | 186 | }, $name); |
187 | 187 | $this->tag[$key] = new TagSet($name, $this); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function getTagKey(string $tag): string |
212 | 212 | { |
213 | - return $this->options['tag_prefix'] . md5($tag); |
|
213 | + return $this->options['tag_prefix'].md5($tag); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $this->handler = new \Redis; |
56 | 56 | |
57 | 57 | if ($this->options['persistent']) { |
58 | - $this->handler->pconnect($this->options['host'], (int) $this->options['port'], $this->options['timeout'], 'persistent_id_' . $this->options['select']); |
|
58 | + $this->handler->pconnect($this->options['host'], (int) $this->options['port'], $this->options['timeout'], 'persistent_id_'.$this->options['select']); |
|
59 | 59 | } else { |
60 | 60 | $this->handler->connect($this->options['host'], (int) $this->options['port'], $this->options['timeout']); |
61 | 61 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\cache\driver; |
14 | 14 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | if (empty($this->options['path'])) { |
57 | - $this->options['path'] = $app->getRuntimePath() . 'cache' . DIRECTORY_SEPARATOR; |
|
57 | + $this->options['path'] = $app->getRuntimePath().'cache'.DIRECTORY_SEPARATOR; |
|
58 | 58 | } elseif (substr($this->options['path'], -1) != DIRECTORY_SEPARATOR) { |
59 | 59 | $this->options['path'] .= DIRECTORY_SEPARATOR; |
60 | 60 | } |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | |
73 | 73 | if ($this->options['cache_subdir']) { |
74 | 74 | // 使用子目录 |
75 | - $name = substr($name, 0, 2) . DIRECTORY_SEPARATOR . substr($name, 2); |
|
75 | + $name = substr($name, 0, 2).DIRECTORY_SEPARATOR.substr($name, 2); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | if ($this->options['prefix']) { |
79 | - $name = $this->options['prefix'] . DIRECTORY_SEPARATOR . $name; |
|
79 | + $name = $this->options['prefix'].DIRECTORY_SEPARATOR.$name; |
|
80 | 80 | } |
81 | 81 | |
82 | - return $this->options['path'] . $name . '.php'; |
|
82 | + return $this->options['path'].$name.'.php'; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $data = gzcompress($data, 3); |
171 | 171 | } |
172 | 172 | |
173 | - $data = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data; |
|
173 | + $data = "<?php\n//".sprintf('%012d', $expire)."\n exit();?>\n".$data; |
|
174 | 174 | $result = file_put_contents($filename, $data); |
175 | 175 | |
176 | 176 | if ($result) { |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | { |
248 | 248 | $this->writeTimes++; |
249 | 249 | |
250 | - $files = (array) glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DIRECTORY_SEPARATOR : '') . '*'); |
|
250 | + $files = (array) glob($this->options['path'].($this->options['prefix'] ? $this->options['prefix'].DIRECTORY_SEPARATOR : '').'*'); |
|
251 | 251 | |
252 | 252 | foreach ($files as $path) { |
253 | 253 | if (is_dir($path)) { |
254 | - $matches = glob($path . DIRECTORY_SEPARATOR . '*.php'); |
|
254 | + $matches = glob($path.DIRECTORY_SEPARATOR.'*.php'); |
|
255 | 255 | if (is_array($matches)) { |
256 | 256 | array_map('unlink', $matches); |
257 | 257 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\cache; |
14 | 14 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\session\driver; |
14 | 14 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function read(string $sessID): string |
91 | 91 | { |
92 | - return (string) $this->handler->get($this->config['prefix'] . $sessID); |
|
92 | + return (string) $this->handler->get($this->config['prefix'].$sessID); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function write(string $sessID, string $data): bool |
103 | 103 | { |
104 | - return $this->handler->set($this->config['prefix'] . $sessID, $data, $this->config['expire']); |
|
104 | + return $this->handler->set($this->config['prefix'].$sessID, $data, $this->config['expire']); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function delete(string $sessID): bool |
114 | 114 | { |
115 | - return $this->handler->delete($this->config['prefix'] . $sessID); |
|
115 | + return $this->handler->delete($this->config['prefix'].$sessID); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\session\driver; |
14 | 14 | |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | foreach ($hosts as $i => $host) { |
63 | 63 | $port = $ports[$i] ?? $ports[0]; |
64 | 64 | $this->config['timeout'] > 0 ? |
65 | - $this->handler->addServer($host, (int) $port, $this->config['persistent'], 1, $this->config['timeout']) : |
|
66 | - $this->handler->addServer($host, (int) $port, $this->config['persistent'], 1); |
|
65 | + $this->handler->addServer($host, (int) $port, $this->config['persistent'], 1, $this->config['timeout']) : $this->handler->addServer($host, (int) $port, $this->config['persistent'], 1); |
|
67 | 66 | } |
68 | 67 | |
69 | 68 | return true; |
@@ -77,7 +76,7 @@ discard block |
||
77 | 76 | */ |
78 | 77 | public function read(string $sessID): string |
79 | 78 | { |
80 | - return (string) $this->handler->get($this->config['prefix'] . $sessID); |
|
79 | + return (string) $this->handler->get($this->config['prefix'].$sessID); |
|
81 | 80 | } |
82 | 81 | |
83 | 82 | /** |
@@ -89,7 +88,7 @@ discard block |
||
89 | 88 | */ |
90 | 89 | public function write(string $sessID, string $data): bool |
91 | 90 | { |
92 | - return $this->handler->set($this->config['prefix'] . $sessID, $data, 0, $this->config['expire']); |
|
91 | + return $this->handler->set($this->config['prefix'].$sessID, $data, 0, $this->config['expire']); |
|
93 | 92 | } |
94 | 93 | |
95 | 94 | /** |
@@ -100,7 +99,7 @@ discard block |
||
100 | 99 | */ |
101 | 100 | public function delete(string $sessID): bool |
102 | 101 | { |
103 | - return $this->handler->delete($this->config['prefix'] . $sessID); |
|
102 | + return $this->handler->delete($this->config['prefix'].$sessID); |
|
104 | 103 | } |
105 | 104 | |
106 | 105 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\session\driver; |
14 | 14 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function read(string $sessID): string |
88 | 88 | { |
89 | - return (string) $this->handler->get($this->config['prefix'] . $sessID); |
|
89 | + return (string) $this->handler->get($this->config['prefix'].$sessID); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | public function write(string $sessID, string $data): bool |
100 | 100 | { |
101 | 101 | if ($this->config['expire'] > 0) { |
102 | - $result = $this->handler->setex($this->config['prefix'] . $sessID, $this->config['expire'], $data); |
|
102 | + $result = $this->handler->setex($this->config['prefix'].$sessID, $this->config['expire'], $data); |
|
103 | 103 | } else { |
104 | - $result = $this->handler->set($this->config['prefix'] . $sessID, $data); |
|
104 | + $result = $this->handler->set($this->config['prefix'].$sessID, $data); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $result ? true : false; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function delete(string $sessID): bool |
117 | 117 | { |
118 | - return $this->handler->delete($this->config['prefix'] . $sessID) > 0; |
|
118 | + return $this->handler->delete($this->config['prefix'].$sessID) > 0; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\session\driver; |
14 | 14 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $this->config = array_merge($this->config, $config); |
35 | 35 | |
36 | 36 | if (empty($this->config['path'])) { |
37 | - $this->config['path'] = $app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . 'session' . DIRECTORY_SEPARATOR; |
|
37 | + $this->config['path'] = $app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.'session'.DIRECTORY_SEPARATOR; |
|
38 | 38 | } elseif (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { |
39 | 39 | $this->config['path'] .= DIRECTORY_SEPARATOR; |
40 | 40 | } |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | public function gc() |
73 | 73 | { |
74 | 74 | $maxlifetime = $this->config['gc_maxlifetime']; |
75 | - $list = glob($this->config['path'] . '*'); |
|
75 | + $list = glob($this->config['path'].'*'); |
|
76 | 76 | |
77 | 77 | foreach ($list as $path) { |
78 | 78 | if (is_dir($path)) { |
79 | - $files = glob($path . DIRECTORY_SEPARATOR . '*.php'); |
|
79 | + $files = glob($path.DIRECTORY_SEPARATOR.'*.php'); |
|
80 | 80 | foreach ($files as $file) { |
81 | 81 | if (time() > filemtime($file) + $maxlifetime) { |
82 | 82 | unlink($file); |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | { |
100 | 100 | if ($this->config['prefix']) { |
101 | 101 | // 使用子目录 |
102 | - $name = $this->config['prefix'] . DIRECTORY_SEPARATOR . 'sess_' . $name; |
|
102 | + $name = $this->config['prefix'].DIRECTORY_SEPARATOR.'sess_'.$name; |
|
103 | 103 | } else { |
104 | - $name = 'sess_' . $name; |
|
104 | + $name = 'sess_'.$name; |
|
105 | 105 | } |
106 | 106 | |
107 | - $filename = $this->config['path'] . $name . '.php'; |
|
107 | + $filename = $this->config['path'].$name.'.php'; |
|
108 | 108 | $dir = dirname($filename); |
109 | 109 | |
110 | 110 | if ($auto && !is_dir($dir)) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $data = gzcompress($data, 3); |
175 | 175 | } |
176 | 176 | |
177 | - $data = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data; |
|
177 | + $data = "<?php\n//".sprintf('%012d', $expire)."\n exit();?>\n".$data; |
|
178 | 178 | $result = file_put_contents($filename, $data); |
179 | 179 | |
180 | 180 | if ($result) { |
@@ -8,7 +8,7 @@ |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think; |
14 | 14 |