1 | <?php |
||
26 | final class Space |
||
27 | { |
||
28 | public const VSPACE = 281; |
||
29 | public const VINDEX = 289; |
||
30 | |||
31 | private $client; |
||
32 | private $id; |
||
33 | private $indexes = []; |
||
34 | |||
35 | 62 | public function __construct(Client $client, int $id) |
|
40 | |||
41 | 1 | public function getId() : int |
|
45 | |||
46 | 61 | public function select(array $key = [], $index = 0, int $limit = \PHP_INT_MAX &0xffffffff, int $offset = 0, int $iteratorType = IteratorTypes::EQ) : BinaryResponse |
|
47 | { |
||
48 | 61 | if (\is_string($index)) { |
|
49 | 15 | $index = $this->getIndexIdByName($index); |
|
50 | } |
||
51 | |||
52 | 61 | $request = new SelectRequest($this->id, $index, $key, $offset, $limit, $iteratorType); |
|
53 | |||
54 | 61 | return BinaryResponse::createFromRaw($this->client->sendRequest($request)); |
|
55 | } |
||
56 | |||
57 | 15 | public function insert(array $values) : BinaryResponse |
|
58 | { |
||
59 | 15 | $request = new InsertRequest($this->id, $values); |
|
60 | |||
61 | 15 | return BinaryResponse::createFromRaw($this->client->sendRequest($request)); |
|
62 | } |
||
63 | |||
64 | 1 | public function replace(array $values) : BinaryResponse |
|
70 | |||
71 | 12 | public function update(array $key, array $operations, $index = 0) : BinaryResponse |
|
72 | { |
||
73 | 12 | if (\is_string($index)) { |
|
74 | $index = $this->getIndexIdByName($index); |
||
75 | } |
||
76 | |||
77 | 12 | $request = new UpdateRequest($this->id, $index, $key, $operations); |
|
78 | |||
79 | 12 | return BinaryResponse::createFromRaw($this->client->sendRequest($request)); |
|
80 | } |
||
81 | |||
82 | 1 | public function upsert(array $values, array $operations) : BinaryResponse |
|
88 | |||
89 | 4 | public function delete(array $key, $index = 0) : BinaryResponse |
|
90 | { |
||
91 | 4 | if (\is_string($index)) { |
|
99 | |||
100 | 2 | public function flushIndexes() : void |
|
104 | |||
105 | 16 | private function getIndexIdByName(string $indexName) : int |
|
121 | } |
||
122 |