| 1 |
<?php |
| 2 |
|
| 3 |
namespace Clue\Redis\Protocol; |
| 4 |
|
| 5 |
use Clue\Redis\Protocol\Parser\ParserInterface; |
| 6 |
use Clue\Redis\Protocol\Parser\ResponseParser; |
| 7 |
use Clue\Redis\Protocol\Serializer\SerializerInterface; |
| 8 |
use Clue\Redis\Protocol\Serializer\RecursiveSerializer; |
| 9 |
use Clue\Redis\Protocol\Parser\RequestParser; |
| 10 |
|
| 11 |
/** |
| 12 |
* Provides factory methods used to instantiate the best available protocol implementation |
| 13 |
*/ |
| 14 |
class Factory |
| 15 |
{ |
| 16 |
/** |
| 17 |
* instantiate the best available protocol response parser implementation |
| 18 |
* |
| 19 |
* This is the parser every redis client implementation should use in order |
| 20 |
* to parse incoming response messages from a redis server. |
| 21 |
* |
| 22 |
* @return ParserInterface |
| 23 |
*/ |
| 24 |
public function createResponseParser() |
| 25 |
{ |
| 26 |
return new ResponseParser(); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* instantiate the best available protocol request parser implementation |
| 31 |
* |
| 32 |
* This is most useful for a redis server implementation which needs to |
| 33 |
* process client requests. |
| 34 |
* |
| 35 |
* @return ParserInterface |
| 36 |
*/ |
| 37 |
public function createRequestParser() |
| 38 |
{ |
| 39 |
return new RequestParser(); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* instantiate the best available protocol serializer implementation |
| 44 |
* |
| 45 |
* @return SerializerInterface |
| 46 |
*/ |
| 47 |
public function createSerializer() |
| 48 |
{ |
| 49 |
return new RecursiveSerializer(); |
| 50 |
} |
| 51 |
} |