This changeset simplifies the API by adding a new MysqlClient and removing the existing Factory and ConnectionInterface:
// old
$factory = new React\MySQL\Factory();
$mysql = $factory->createLazyClient('user:pass@localhost/bookstore');
assert($mysql instanceof React\MySQL\ConnectionInterface);
// new
$mysql = new React\MySQL\MysqlClient('user:pass@localhost/bookstore');
The resulting API is somewhat more straight-forward and easier to use. On top of this, this is also one of the prerequisites for introducing the connection pool as discussed in #175.
Internally, the MysqlClient works similar to what was previously called a "lazy" client, but we're getting rid of this wording altogether. This means it automatically creates the underlying connection to MySQL only when it's actually needed and will close this connection after a short while when it is not in use anymore. The changeset introduced in #182 already reduces the default itle time to 1ms (0.001s). A follow-up PR will adjust the open and close event handling as discussed in #147.
For the reference: I realize the changeset looks pretty big, but if you take a look at the individual commits, you will see that most of this comes from rearranging existing code. I've tried hard to keep the existing logic in place otherwise to not introduce any side effects.
This changeset simplifies the API by adding a new
MysqlClient
and removing the existingFactory
andConnectionInterface
:The resulting API is somewhat more straight-forward and easier to use. On top of this, this is also one of the prerequisites for introducing the connection pool as discussed in #175.
Internally, the
MysqlClient
works similar to what was previously called a "lazy" client, but we're getting rid of this wording altogether. This means it automatically creates the underlying connection to MySQL only when it's actually needed and will close this connection after a short while when it is not in use anymore. The changeset introduced in #182 already reduces the default itle time to 1ms (0.001s). A follow-up PR will adjust theopen
andclose
event handling as discussed in #147.For the reference: I realize the changeset looks pretty big, but if you take a look at the individual commits, you will see that most of this comes from rearranging existing code. I've tried hard to keep the existing logic in place otherwise to not introduce any side effects.
Builds on top of #87, #182 and #185 Refs #147 and https://github.com/clue/reactphp-redis/pull/129