File tree Expand file tree Collapse file tree 4 files changed +88
-3
lines changed Expand file tree Collapse file tree 4 files changed +88
-3
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,16 @@ class HttpClient
4141 ];
4242
4343 /**
44+ * Global options for request
45+ *
46+ * [
47+ * 'method' => 'GET',
48+ * 'data' => 'string|array',
49+ * 'headers' => [key => value],
50+ * 'cookies' => [key => value],
51+ * 'settings' => [key => value],
52+ * ]
53+ *
4454 * @var array
4555 */
4656 private $ options = [];
Original file line number Diff line number Diff line change 22
33namespace Swoft \Swlib ;
44
5+ use InvalidArgumentException ;
6+
57/**
68 * Class MemFactory
79 */
810final class MemFactory
911{
12+ /**
13+ * @var MemTable[]
14+ */
15+ private static $ tables = [];
16+
17+ /**
18+ * @param string $name
19+ * @param int $size
20+ * @param array $columns
21+ *
22+ * @return MemTable
23+ */
24+ public static function create (string $ name , int $ size = 0 , array $ columns = []): MemTable
25+ {
26+ $ table = new MemTable ($ name , $ size , $ columns );
27+
28+ // Save instance
29+ self ::$ tables [$ name ] = $ table ;
30+ return $ table ;
31+ }
32+
33+ /**
34+ * @param string $name
35+ *
36+ * @return MemTable
37+ */
38+ public static function get (string $ name ): MemTable
39+ {
40+ if (isset (self ::$ tables [$ name ])) {
41+ return self ::$ tables [$ name ];
42+ }
43+
44+ throw new InvalidArgumentException ('The memory table instance is not exists ' );
45+ }
46+
47+ /**
48+ * @param string $name
49+ * @param MemTable $table
50+ */
51+ public static function set (string $ name , MemTable $ table ): void
52+ {
53+ self ::$ tables [$ name ] = $ table ;
54+ }
55+
56+ /**
57+ * @param string $name
58+ *
59+ * @return bool
60+ */
61+ public static function del (string $ name ): bool
62+ {
63+ if (isset (self ::$ tables [$ name ])) {
64+ unset(self ::$ tables [$ name ]);
65+ return true ;
66+ }
67+
68+ return false ;
69+ }
70+
71+ /**
72+ * Clear all tables
73+ *
74+ * @param bool $clearData
75+ */
76+ public static function clear (bool $ clearData = true ): void
77+ {
78+ foreach (self ::$ tables as $ name => $ table ) {
79+ if ($ clearData ) {
80+ $ table ->clear ();
81+ }
1082
83+ unset(self ::$ tables [$ name ]);
84+ }
85+ }
1186}
Original file line number Diff line number Diff line change @@ -267,15 +267,15 @@ public function each(callable $fn): void
267267 }
268268
269269 /**
270- * clear /flush table data
270+ * Clear /flush table data
271271 */
272272 public function clear (): void
273273 {
274274 $ this ->flush ();
275275 }
276276
277277 /**
278- * clear /flush table data
278+ * Clear /flush table data
279279 */
280280 public function flush (): void
281281 {
Original file line number Diff line number Diff line change 1717/**
1818 * Class BenchTesting
1919 *
20- * from https://github.com/swoole/swoole-src/blob/master/benchmark/src/Base.php
20+ * @link https://github.com/swoole/swoole-src/blob/master/benchmark/src/Base.php
2121 */
2222class SwooleBench
2323{
You can’t perform that action at this time.
0 commit comments