Skip to content

Commit

Permalink
implemented WaitAOF command for the redis ver7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NikanV committed Jun 16, 2023
1 parent b1800df commit d0705f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,13 @@ func (c cmdable) Wait(ctx context.Context, numSlaves int, timeout time.Duration)
return cmd
}

func (c cmdable) WaitAOF(ctx context.Context, numLocal, numSlaves int, timeout time.Duration) *IntCmd {
cmd := NewIntCmd(ctx, "waitAOF", numLocal, numSlaves, int(timeout/time.Millisecond))
cmd.setReadTimeout(timeout)
_ = c(ctx, cmd)
return cmd
}

func (c statefulCmdable) Select(ctx context.Context, index int) *StatusCmd {
cmd := NewStatusCmd(ctx, "select", index)
_ = c(ctx, cmd)
Expand Down
11 changes: 11 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ var _ = Describe("Commands", func() {
Expect(time.Now()).To(BeTemporally("~", start.Add(wait), 3*time.Second))
})

It("should WaitAOF", func() {
const waitAOF = 3 * time.Second

// assuming that the redis instance doesn't have AOF enabled
start := time.Now()
val, err := client.WaitAOF(ctx, 0, 1, waitAOF).Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal(int64(0)))
Expect(time.Now()).To(BeTemporally("~", start.Add(waitAOF), 3*time.Second))
})

It("should Select", func() {
pipe := client.Pipeline()
sel := pipe.Select(ctx, 1)
Expand Down

0 comments on commit d0705f1

Please sign in to comment.