diff options
| author | alex <[email protected]> | 2026-07-12 15:00:16 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-12 15:00:16 +0200 |
| commit | 6cb3313793bf45e197b3048f0abd2f600bf97bb5 (patch) | |
| tree | 019a0995c7f9422ec9d739c77379ee7cc1a96b9c /main.go | |
| parent | ce9d9f8b2183bc0a31bfa40e780ae07182bc7cf8 (diff) | |
| download | redis-clone-multi/execute.tar.xz redis-clone-multi/execute.zip | |
multi exec and discardmulti/execute
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -69,6 +69,7 @@ func handleConnection(conn net.Conn) { conn.Close() }() fmt.Println("Client connected:", conn.RemoteAddr()) + session := commands.NewClientSession() // <-- Create connection session reader := bufio.NewReader(conn) for { @@ -84,15 +85,22 @@ func handleConnection(conn net.Conn) { fmt.Printf("Parsed RESP Arguments: %v\n", args) - command := strings.ToUpper(args[0]) + args[0] = strings.ToUpper(args[0]) + commandName := args[0] - if cmd , ok := commands.PubSubRegistry[command]; ok { + if cmd, ok := commands.SessionRegistry[commandName]; ok { + commands.DispatchSession(db,conn, session, cmd, args) + } else if cmd, ok := commands.PubSubRegistry[commandName]; ok { commands.DispatchPubSub(conn, &hub, cmd, args) - } else if cmd, ok := commands.BaseRegistry[command]; ok { + } else if cmd, ok := commands.BaseRegistry[commandName]; ok { + if session.InTransaction { + commands.QueueBaseCommand(conn, session, args, cmd.MinArgs) + } else { res := commands.DispatchBaseCommand(db, cmd, args) conn.Write(core.SerializeRESP(res)) + } } else { - conn.Write(core.SerializeRESP(fmt.Errorf("ERR unknown command '%s'", command))) - } + conn.Write(core.SerializeRESP(fmt.Errorf("-ERR unknown command '%s'", commandName))) +} } }
\ No newline at end of file |
