Example #1
0
func IsMultiCmd(cmd *resp.Command) (multiKey bool, numKeys int) {
	multiKey = true
	switch cmd.Name() {
	case "MGET":
		numKeys = len(cmd.Args) - 1
	case "MSET":
		numKeys = (len(cmd.Args) - 1) / 2
	case "DEL":
		numKeys = len(cmd.Args) - 1
	default:
		multiKey = false
	}
	return
}
Example #2
0
func NewMultiKeyCmd(cmd *resp.Command, numSubCmds int) *MultiKeyCmd {
	mc := &MultiKeyCmd{
		cmd:               cmd,
		numSubCmds:        numSubCmds,
		numPendingSubCmds: numSubCmds,
	}
	switch cmd.Name() {
	case "MGET":
		mc.cmdType = MGET
	case "MSET":
		mc.cmdType = MSET
	case "DEL":
		mc.cmdType = DEL
	default:
		panic("not multi key command")
	}
	mc.subCmdRsps = make([]*PipelineResponse, numSubCmds)
	return mc
}
Example #3
0
func CmdFlag(cmd *resp.Command) int {
	return cmdFlagMap[cmd.Name()]
}