@@ -409,12 +409,35 @@ private function select(): string {
409409 return $ servers .$ databases ;
410410 }
411411
412+ private function slowlog (): string {
413+ if (isset ($ _GET ['resetlog ' ])) {
414+ $ this ->redis ->rawCommand ('SLOWLOG ' , 'RESET ' );
415+ Http::redirect (['tab ' ]);
416+ }
417+
418+ if (isset ($ _POST ['save ' ])) {
419+ $ this ->redis ->config ('SET ' , 'slowlog-max-len ' , Http::post ('slowlog_max_items ' , '50 ' ));
420+ $ this ->redis ->config ('SET ' , 'slowlog-log-slower-than ' , Http::post ('slowlog_slower_than ' , '1000 ' ));
421+ Http::redirect (['tab ' ]);
422+ }
423+
424+ $ slowlog_max_items = $ this ->redis ->config ('GET ' , 'slowlog-max-len ' )['slowlog-max-len ' ];
425+ $ slowlog_items = $ this ->redis ->rawCommand ('SLOWLOG ' , 'GET ' , $ slowlog_max_items );
426+ $ slowlog_slower_than = $ this ->redis ->config ('GET ' , 'slowlog-log-slower-than ' )['slowlog-log-slower-than ' ];
427+
428+ return $ this ->template ->render ('dashboards/redis/redis ' , [
429+ 'slowlog ' => [
430+ 'items ' => $ slowlog_items ?? [],
431+ 'max_items ' => $ slowlog_max_items ?? '' ,
432+ 'slower_than ' => $ slowlog_slower_than ?? '' ,
433+ ],
434+ ]);
435+ }
436+
412437 /**
413438 * @throws Exception
414439 */
415440 private function mainDashboard (): string {
416- $ keys = $ this ->getAllKeys ();
417-
418441 if (isset ($ _POST ['submit_import_key ' ])) {
419442 Helpers::import (
420443 function (string $ key ): bool {
@@ -429,22 +452,11 @@ function (string $key, string $value, int $ttl): bool {
429452 }
430453
431454 if (Http::get ('tab ' ) === 'slowlog ' ) {
432- if (isset ($ _GET ['resetlog ' ])) {
433- $ this ->redis ->rawCommand ('SLOWLOG ' , 'RESET ' );
434- Http::redirect (['tab ' ]);
435- }
436-
437- if (isset ($ _POST ['save ' ])) {
438- $ this ->redis ->config ('SET ' , 'slowlog-max-len ' , Http::post ('slowlog_max_items ' , '50 ' ));
439- $ this ->redis ->config ('SET ' , 'slowlog-log-slower-than ' , Http::post ('slowlog_slower_than ' , '1000 ' ));
440- Http::redirect (['tab ' ]);
441- }
442-
443- $ slowlog_max_items = $ this ->redis ->config ('GET ' , 'slowlog-max-len ' )['slowlog-max-len ' ];
444- $ slowlog_items = $ this ->redis ->rawCommand ('SLOWLOG ' , 'GET ' , $ slowlog_max_items );
445- $ slowlog_slower_than = $ this ->redis ->config ('GET ' , 'slowlog-log-slower-than ' )['slowlog-log-slower-than ' ];
455+ return $ this ->slowlog ();
446456 }
447457
458+ $ keys = $ this ->getAllKeys ();
459+
448460 if (isset ($ _GET ['export_btn ' ])) {
449461 Helpers::export ($ keys , 'redis_backup ' , fn (string $ key ): string => bin2hex ($ this ->redis ->dump ($ key )));
450462 }
@@ -456,11 +468,6 @@ function (string $key, string $value, int $ttl): bool {
456468 'all_keys ' => $ this ->redis ->dbSize (),
457469 'paginator ' => $ paginator ->render (),
458470 'view_key ' => Http::queryString (['db ' , 's ' ], ['view ' => 'key ' , 'key ' => '__key__ ' ]),
459- 'slowlog ' => [
460- 'items ' => $ slowlog_items ?? [],
461- 'max_items ' => $ slowlog_max_items ?? '' ,
462- 'slower_than ' => $ slowlog_slower_than ?? '' ,
463- ],
464471 ]);
465472 }
466473}
0 commit comments