mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 00:42:43 +08:00

wip: raft does not care about migrating wip: optimize code wip: raft election wip wip: fix raft leader missing log entries wip fix a dead lock batch set slot route wip: raft persist wip refactor cluster suite remove relay rename relay2 refactor: allow customizing client factory test raft refactor re-balance avoid errors caused by inconsistent status on follower nodes during raft commits test raft election
28 lines
742 B
Go
28 lines
742 B
Go
package cluster
|
|
|
|
import (
|
|
"github.com/hdt3213/godis/interface/redis"
|
|
"github.com/hdt3213/godis/redis/protocol"
|
|
)
|
|
|
|
// FlushDB removes all data in current database
|
|
func FlushDB(cluster *Cluster, c redis.Connection, cmdLine [][]byte) redis.Reply {
|
|
replies := cluster.broadcast(c, modifyCmd(cmdLine, "FlushDB_"))
|
|
var errReply protocol.ErrorReply
|
|
for _, v := range replies {
|
|
if protocol.IsErrorReply(v) {
|
|
errReply = v.(protocol.ErrorReply)
|
|
break
|
|
}
|
|
}
|
|
if errReply == nil {
|
|
return &protocol.OkReply{}
|
|
}
|
|
return protocol.MakeErrReply("error occurs: " + errReply.Error())
|
|
}
|
|
|
|
// FlushAll removes all data in cluster
|
|
func FlushAll(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
|
|
return FlushDB(cluster, c, args)
|
|
}
|