1 | <?php |
||
20 | class RedisCli extends Abstraction implements Executable |
||
21 | { |
||
22 | use OptionMasker; |
||
23 | |||
24 | /** |
||
25 | * List of implemented redis commands |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | private $availableCommands = ['BGSAVE' => true, 'LASTSAVE' => true]; |
||
30 | |||
31 | /** |
||
32 | * Redis command to execute |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $command; |
||
37 | |||
38 | /** |
||
39 | * Host to connect to |
||
40 | * -h |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | private $host; |
||
45 | |||
46 | /** |
||
47 | * Port to connect to |
||
48 | * -p |
||
49 | * |
||
50 | * @var integer |
||
51 | */ |
||
52 | private $port; |
||
53 | |||
54 | |||
55 | /** |
||
56 | * Password to connect |
||
57 | * -a |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | private $password; |
||
62 | |||
63 | /** |
||
64 | * Constructor. |
||
65 | * |
||
66 | * @param string $path |
||
67 | */ |
||
68 | 13 | public function __construct(string $path = '') |
|
73 | |||
74 | /** |
||
75 | * Set the redis-cli command to execute. |
||
76 | * |
||
77 | * @param string $command |
||
78 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
79 | * @throws \phpbu\App\Exception |
||
80 | */ |
||
81 | 12 | public function runCommand(string $command) : RedisCli |
|
89 | |||
90 | /** |
||
91 | * Execute redis-cli BGSAVE command. |
||
92 | * |
||
93 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
94 | * @throws \phpbu\App\Exception |
||
95 | */ |
||
96 | 10 | public function backup() : RedisCli |
|
100 | |||
101 | /** |
||
102 | * Execute redis-cli LASTSAVE command. |
||
103 | * |
||
104 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
105 | * @throws \phpbu\App\Exception |
||
106 | */ |
||
107 | 6 | public function lastBackupTime() : RedisCli |
|
111 | |||
112 | /** |
||
113 | * Host to connect to. |
||
114 | * |
||
115 | * @param string $host |
||
116 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
117 | */ |
||
118 | 7 | public function useHost(string $host) : RedisCli |
|
123 | |||
124 | /** |
||
125 | * Port to connect to. |
||
126 | * |
||
127 | * @param int $port |
||
128 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
129 | */ |
||
130 | 7 | public function usePort(int $port) : RedisCli |
|
135 | |||
136 | /** |
||
137 | * Password to authenticate. |
||
138 | * |
||
139 | * @param string $password |
||
140 | * @return \phpbu\App\Cli\Executable\RedisCli |
||
141 | */ |
||
142 | 7 | public function usePassword(string $password) : RedisCli |
|
147 | |||
148 | /** |
||
149 | * RedisCli CommandLine generator. |
||
150 | * |
||
151 | * @return \SebastianFeldmann\Cli\CommandLine |
||
152 | * @throws \phpbu\App\Exception |
||
153 | */ |
||
154 | 12 | protected function createCommandLine() : CommandLine |
|
169 | |||
170 | /** |
||
171 | * Set the openssl command line options. |
||
172 | * |
||
173 | * @param \SebastianFeldmann\Cli\Command\Executable $cmd |
||
174 | */ |
||
175 | 11 | protected function setOptions(Cmd $cmd) |
|
181 | } |
||
182 |