Skip to content

Commit

Permalink
refactor: Refactor the feature of flush db before sync
Browse files Browse the repository at this point in the history
  • Loading branch information
jjz921024 committed Dec 26, 2023
1 parent 2cca49d commit 80b00ba
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
11 changes: 4 additions & 7 deletions cmd/redis-shake/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,10 @@ func main() {
log.Infof("create RedisStandaloneWriter: %v", opts.Address)
}
if config.Opt.Advanced.EmptyDBBeforeSync {
if opts.OffReply {
entry := entry.NewEntry()
entry.Argv = []string{"FLUSHALL"}
theWriter.Write(entry)
} else {
theWriter.Flush()
}
// exec FLUSHALL command to flush db
entry := entry.NewEntry()
entry.Argv = []string{"FLUSHALL"}
theWriter.Write(entry)
}
} else {
log.Panicf("no writer config entry found")
Expand Down
1 change: 0 additions & 1 deletion internal/writer/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ import (
type Writer interface {
status.Statusable
Write(entry *entry.Entry)
Flush()
Close()
}
6 changes: 0 additions & 6 deletions internal/writer/redis_cluster_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ func NewRedisClusterWriter(opts *RedisWriterOptions) Writer {
return rw
}

func (r *RedisClusterWriter) Flush() {
for _, writer := range r.writers {
writer.Flush()
}
}

func (r *RedisClusterWriter) Close() {
for _, writer := range r.writers {
writer.Close()
Expand Down
7 changes: 0 additions & 7 deletions internal/writer/redis_standalone_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ func NewRedisStandaloneWriter(opts *RedisWriterOptions) Writer {
return rw
}

func (w *redisStandaloneWriter) Flush() {
reply := w.client.DoWithStringReply("FLUSHALL")
if reply != "OK" {
log.Panicf("flush failed with reply: %s", reply)
}
}

func (w *redisStandaloneWriter) Close() {
if !w.offReply {
close(w.chWaitReply)
Expand Down

0 comments on commit 80b00ba

Please sign in to comment.