1313namespace RobiNN \Pca \Dashboards \Redis ;
1414
1515use Redis ;
16+ use RedisException ;
1617use RobiNN \Pca \Dashboards \DashboardException ;
1718use RobiNN \Pca \Helpers ;
1819use RobiNN \Pca \Http ;
@@ -65,7 +66,7 @@ private function serverInfo(array $servers): array {
6566 'Memory used ' => Helpers::formatBytes ($ server_info ['used_memory ' ]),
6667 'Keys ' => Helpers::formatNumber ($ all_keys ).' (all databases) ' ,
6768 ];
68- } catch (DashboardException $ e ) {
69+ } catch (DashboardException | RedisException $ e ) {
6970 $ data = [
7071 'error ' => $ e ->getMessage (),
7172 ];
@@ -80,6 +81,7 @@ private function serverInfo(array $servers): array {
8081 * @param Redis $redis
8182 *
8283 * @return string
84+ * @throws RedisException
8385 */
8486 private function deleteAllKeys (Redis $ redis ): string {
8587 if ($ redis ->flushDB ()) {
@@ -97,6 +99,7 @@ private function deleteAllKeys(Redis $redis): string {
9799 * @param Redis $redis
98100 *
99101 * @return string
102+ * @throws RedisException
100103 */
101104 private function deleteKey (Redis $ redis ): string {
102105 $ keys = explode (', ' , Http::get ('delete ' ));
@@ -119,6 +122,7 @@ private function deleteKey(Redis $redis): string {
119122 * @param Redis $redis
120123 *
121124 * @return array<string, mixed>
125+ * @throws RedisException
122126 */
123127 private function getInfo (Redis $ redis ): array {
124128 $ options = ['SERVER ' , 'CLIENTS ' , 'MEMORY ' , 'PERSISTENCE ' , 'STATS ' , 'REPLICATION ' , 'CPU ' , 'CLASTER ' , 'KEYSPACE ' , 'COMANDSTATS ' ];
@@ -166,7 +170,7 @@ private function moreInfo(array $servers): string {
166170 'array ' => $ this ->getInfo ($ redis ),
167171 'bottom_content ' => method_exists ($ redis , 'resetStat ' ) && isset ($ reset_link ) ? $ reset_link : '' ,
168172 ]);
169- } catch (DashboardException $ e ) {
173+ } catch (DashboardException | RedisException $ e ) {
170174 return $ e ->getMessage ();
171175 }
172176 }
@@ -177,6 +181,7 @@ private function moreInfo(array $servers): string {
177181 * @param Redis $redis
178182 *
179183 * @return array<int, string>
184+ * @throws RedisException
180185 */
181186 private function getDatabases (Redis $ redis ): array {
182187 $ databases = [];
@@ -207,6 +212,7 @@ private function getDatabases(Redis $redis): array {
207212 * @param Redis $redis
208213 *
209214 * @return array<int, array<string, string|int>>
215+ * @throws RedisException
210216 */
211217 private function getAllKeys (Redis $ redis ): array {
212218 static $ keys = [];
@@ -235,6 +241,7 @@ private function getAllKeys(Redis $redis): array {
235241 * @param Redis $redis
236242 *
237243 * @return string
244+ * @throws RedisException
238245 */
239246 private function mainDashboard (Redis $ redis ): string {
240247 $ keys = $ this ->getAllKeys ($ redis );
@@ -264,6 +271,7 @@ private function mainDashboard(Redis $redis): string {
264271 * @param Redis $redis
265272 *
266273 * @return string
274+ * @throws RedisException
267275 */
268276 private function viewKey (Redis $ redis ): string {
269277 $ key = Http::get ('key ' );
@@ -342,6 +350,7 @@ private function viewKey(Redis $redis): string {
342350 * @param Redis $redis
343351 *
344352 * @return void
353+ * @throws RedisException
345354 */
346355 private function import (Redis $ redis ): void {
347356 if ($ _FILES ['import ' ]['type ' ] === 'application/octet-stream ' ) {
@@ -366,6 +375,7 @@ private function import(Redis $redis): void {
366375 * @param Redis $redis
367376 *
368377 * @return string
378+ * @throws RedisException
369379 */
370380 private function form (Redis $ redis ): string {
371381 $ key = Http::get ('key ' );
0 commit comments