File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -417,21 +417,33 @@ protected function bgsaveResponses(): array
417417 ];
418418 }
419419
420+ /**
421+ * Override for cluster - info() requires a route parameter and checks all primaries.
422+ */
423+ protected function isSaveInProgress (): bool
424+ {
425+ $ info = $ this ->valkey_glide ->info ('allPrimaries ' , 'persistence ' );
426+ foreach ($ info as $ nodeInfo ) {
427+ if (
428+ $ nodeInfo ['rdb_bgsave_in_progress ' ] == '1 '
429+ || $ nodeInfo ['aof_rewrite_in_progress ' ] == '1 '
430+ ) {
431+ return true ;
432+ }
433+ }
434+ return false ;
435+ }
436+
420437 /**
421438 * Override for cluster - info() requires a route parameter.
422439 */
423440 protected function waitForSaveNotInProgress ()
424441 {
425- $ this ->waitFor (function () {
426- $ info = $ this ->valkey_glide ->info ('allPrimaries ' , 'persistence ' );
427- foreach ($ info as $ nodeInfo ) {
428- if ($ nodeInfo ['rdb_bgsave_in_progress ' ] == '1 '
429- || $ nodeInfo ['aof_rewrite_in_progress ' ] == '1 ' ) {
430- return false ;
431- }
432- }
433- return true ;
434- }, 10 , 'Timed out waiting for background save to complete on cluster ' );
442+ $ this ->waitFor (
443+ fn () => !$ this ->isSaveInProgress (),
444+ 10 ,
445+ 'Timed out waiting for background save to complete on cluster '
446+ );
435447 }
436448
437449 public function testBgSave ()
Original file line number Diff line number Diff line change @@ -2638,16 +2638,26 @@ protected function bgsaveResponses(): array
26382638 ];
26392639 }
26402640
2641+ /**
2642+ * Returns true if a background save (RDB or AOF) is currently in progress.
2643+ */
2644+ protected function isSaveInProgress (): bool
2645+ {
2646+ $ info = $ this ->valkey_glide ->info ('persistence ' );
2647+ return $ info ['rdb_bgsave_in_progress ' ] == '1 '
2648+ || $ info ['aof_rewrite_in_progress ' ] == '1 ' ;
2649+ }
2650+
26412651 /**
26422652 * Helper method to wait for any background save operations to complete.
26432653 */
26442654 protected function waitForSaveNotInProgress ()
26452655 {
2646- $ this ->waitFor (function () {
2647- $ info = $ this ->valkey_glide -> info ( ' persistence ' );
2648- return $ info [ ' rdb_bgsave_in_progress ' ] != ' 1 '
2649- && $ info [ ' aof_rewrite_in_progress ' ] != ' 1 ' ;
2650- }, 10 , ' Timed out waiting for background save to complete ' );
2656+ $ this ->waitFor (
2657+ fn () => ! $ this ->isSaveInProgress (),
2658+ 10 ,
2659+ ' Timed out waiting for background save to complete '
2660+ );
26512661 }
26522662
26532663 public function testTTL ()
You can’t perform that action at this time.
0 commit comments