Skip to content

Commit

Permalink
update some info
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 10, 2019
1 parent 05ab750 commit b5caf11
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class HttpClient
];

/**
* Global options for request
*
* [
* 'method' => 'GET',
* 'data' => 'string|array',
* 'headers' => [key => value],
* 'cookies' => [key => value],
* 'settings' => [key => value],
* ]
*
* @var array
*/
private $options = [];
Expand Down
75 changes: 75 additions & 0 deletions src/MemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,85 @@

namespace Swoft\Swlib;

use InvalidArgumentException;

/**
* Class MemFactory
*/
final class MemFactory
{
/**
* @var MemTable[]
*/
private static $tables = [];

/**
* @param string $name
* @param int $size
* @param array $columns
*
* @return MemTable
*/
public static function create(string $name, int $size = 0, array $columns = []): MemTable
{
$table = new MemTable($name, $size, $columns);

// Save instance
self::$tables[$name] = $table;
return $table;
}

/**
* @param string $name
*
* @return MemTable
*/
public static function get(string $name): MemTable
{
if (isset(self::$tables[$name])) {
return self::$tables[$name];
}

throw new InvalidArgumentException('The memory table instance is not exists');
}

/**
* @param string $name
* @param MemTable $table
*/
public static function set(string $name, MemTable $table): void
{
self::$tables[$name] = $table;
}

/**
* @param string $name
*
* @return bool
*/
public static function del(string $name): bool
{
if (isset(self::$tables[$name])) {
unset(self::$tables[$name]);
return true;
}

return false;
}

/**
* Clear all tables
*
* @param bool $clearData
*/
public static function clear(bool $clearData = true): void
{
foreach (self::$tables as $name => $table) {
if ($clearData) {
$table->clear();
}

unset(self::$tables[$name]);
}
}
}
4 changes: 2 additions & 2 deletions src/MemTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ public function each(callable $fn): void
}

/**
* clear/flush table data
* Clear/flush table data
*/
public function clear(): void
{
$this->flush();
}

/**
* clear/flush table data
* Clear/flush table data
*/
public function flush(): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/SwooleBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Class BenchTesting
*
* from https://github.com/swoole/swoole-src/blob/master/benchmark/src/Base.php
* @link https://github.com/swoole/swoole-src/blob/master/benchmark/src/Base.php
*/
class SwooleBench
{
Expand Down

0 comments on commit b5caf11

Please sign in to comment.