@@ -60,8 +60,7 @@ Once [installed](#install), you can use the following code to connect to your
6060local Redis server and send some requests:
6161
6262``` php
63- $loop = React\EventLoop\Factory::create();
64- $factory = new Clue\React\Redis\Factory($loop);
63+ $factory = new Clue\React\Redis\Factory();
6564
6665$client = $factory->createLazyClient('localhost');
6766$client->set('greeting', 'Hello world');
@@ -78,8 +77,6 @@ $client->incr('invocation')->then(function ($n) {
7877
7978// end connection once all pending requests have been resolved
8079$client->end();
81-
82- $loop->run();
8380```
8481
8582See also the [ examples] ( examples ) .
@@ -89,18 +86,22 @@ See also the [examples](examples).
8986### Factory
9087
9188The ` Factory ` is responsible for creating your [ ` Client ` ] ( #client ) instance.
92- It also registers everything with the main [ ` EventLoop ` ] ( https://github.com/reactphp/event-loop#usage ) .
9389
9490``` php
95- $loop = \React\EventLoop\Factory::create();
96- $factory = new \Clue\React\Redis\Factory($loop);
91+ $factory = new Clue\React\Redis\Factory();
9792```
9893
94+ This class takes an optional ` LoopInterface|null $loop ` parameter that can be used to
95+ pass the event loop instance to use for this object. You can use a ` null ` value
96+ here in order to use the [ default loop] ( https://github.com/reactphp/event-loop#loop ) .
97+ This value SHOULD NOT be given unless you're sure you want to explicitly use a
98+ given event loop instance.
99+
99100If you need custom DNS, proxy or TLS settings, you can explicitly pass a
100101custom instance of the [ ` ConnectorInterface ` ] ( https://github.com/reactphp/socket#connectorinterface ) :
101102
102103``` php
103- $connector = new \ React\Socket\Connector($loop , array(
104+ $connector = new React\Socket\Connector(null , array(
104105 'dns' => '127.0.0.1',
105106 'tcp' => array(
106107 'bindto' => '192.168.10.1:0'
@@ -111,7 +112,7 @@ $connector = new \React\Socket\Connector($loop, array(
111112 )
112113));
113114
114- $factory = new Factory($loop , $connector);
115+ $factory = new Clue\React\Redis\ Factory(null , $connector);
115116```
116117
117118#### createClient()
@@ -146,7 +147,7 @@ connection attempt and/or Redis authentication.
146147``` php
147148$promise = $factory->createClient($redisUri);
148149
149- $loop-> addTimer(3.0, function () use ($promise) {
150+ Loop:: addTimer(3.0, function () use ($promise) {
150151 $promise->cancel();
151152});
152153```
@@ -466,7 +467,7 @@ respectively:
466467``` php
467468$client->subscribe('user');
468469
469- $loop-> addTimer(60.0, function () use ($client) {
470+ Loop:: addTimer(60.0, function () use ($client) {
470471 $client->unsubscribe('user');
471472});
472473```
0 commit comments