github.com/hdt3213/godis@v1.2.9/cluster/keys.go (about)

     1  package cluster
     2  
     3  import (
     4  	"github.com/hdt3213/godis/interface/redis"
     5  	"github.com/hdt3213/godis/redis/protocol"
     6  )
     7  
     8  // FlushDB removes all data in current database
     9  func FlushDB(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
    10  	replies := cluster.broadcast(c, args)
    11  	var errReply protocol.ErrorReply
    12  	for _, v := range replies {
    13  		if protocol.IsErrorReply(v) {
    14  			errReply = v.(protocol.ErrorReply)
    15  			break
    16  		}
    17  	}
    18  	if errReply == nil {
    19  		return &protocol.OkReply{}
    20  	}
    21  	return protocol.MakeErrReply("error occurs: " + errReply.Error())
    22  }
    23  
    24  // FlushAll removes all data in cluster
    25  func FlushAll(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
    26  	return FlushDB(cluster, c, args)
    27  }