Debian Codegraph @

vendor/clue/redis-protocol/src/Serializer/SerializerInterface.php

raw
1 <?php
2
3 namespace Clue\Redis\Protocol\Serializer;
4
5 use Clue\Redis\Protocol\Model\ModelInterface;
6 use Clue\Redis\Protocol\Model\MultiBulkReply;
7
8 interface SerializerInterface
9 {
10 /**
11 * create a serialized unified request protocol message
12 *
13 * This is the *one* method most redis client libraries will likely want to
14 * use in order to send a serialized message (a request) over the* wire to
15 * your redis server instance.
16 *
17 * This method should be used in favor of constructing a request model and
18 * then serializing it. While its effect might be equivalent, this method
19 * is likely to (i.e. it /could/) provide a faster implementation.
20 *
21 * @param string $command
22 * @param array $args
23 * @return string
24 * @see self::createRequestMessage()
25 */
26 public function getRequestMessage($command, array $args = array());
27
28 /**
29 * create a unified request protocol message model
30 *
31 * @param string $command
32 * @param array $args
33 * @return MultiBulkReply
34 */
35 public function createRequestModel($command, array $args = array());
36
37 /**
38 * create a serialized unified protocol reply message
39 *
40 * This is most useful for a redis server implementation which needs to
41 * process client requests and send resulting reply messages.
42 *
43 * This method does its best to guess to right reply type and then returns
44 * a serialized version of the message. It follows the "redis to lua
45 * conversion table" (see link) which means most basic types can be mapped
46 * as is.
47 *
48 * This method should be used in favor of constructing a reply model and
49 * then serializing it. While its effect might be equivalent, this method
50 * is likely to (i.e. it /could/) provide a faster implementation.
51 *
52 * Note however, you may still want to explicitly create a nested reply
53 * model hierarchy if you need more control over the serialized message. For
54 * instance, a null value will always be returned as a Null-Bulk-Reply, so
55 * there's no way to express a Null-Multi-Bulk-Reply, unless you construct
56 * it explicitly.
57 *
58 * @param mixed $data
59 * @return string
60 * @see self::createReplyModel()
61 * @link http://redis.io/commands/eval
62 */
63 public function getReplyMessage($data);
64
65 /**
66 * create response message by determining datatype from given argument
67 *
68 * @param mixed $data
69 * @return ModelInterface
70 */
71 public function createReplyModel($data);
72
73 public function getBulkMessage($data);
74
75 public function getErrorMessage($data);
76
77 public function getIntegerMessage($data);
78
79 public function getMultiBulkMessage($data);
80
81 public function getStatusMessage($data);
82 }