diff --git a/server/client_resp.go b/server/client_resp.go index 475445a..eabc357 100644 --- a/server/client_resp.go +++ b/server/client_resp.go @@ -160,8 +160,8 @@ func (c *respClient) handleRequest(reqData [][]byte) error { c.args = reqData[1:] } - if c.cmd == "xuse" { - err := c.handleUseThenCmd() + if c.cmd == "xselect" { + err := c.handleXSelectCmd() if err != nil { c.resp.writeError(err) c.resp.flush() @@ -182,26 +182,26 @@ func (c *respClient) handleRequest(reqData [][]byte) error { return nil } -// XUSE db THEN command -func (c *respClient) handleUseThenCmd() error { +// XSELECT db THEN command +func (c *respClient) handleXSelectCmd() error { if len(c.args) <= 2 { // invalid command format - return fmt.Errorf("invalid format for XUSE, must XUSE db THEN your command") + return fmt.Errorf("invalid format for XSELECT, must XSELECT db THEN your command") } if hack.String(upperSlice(c.args[1])) != "THEN" { // invalid command format, just resturn here - return fmt.Errorf("invalid format for XUSE, must XUSE db THEN your command") + return fmt.Errorf("invalid format for XSELECT, must XSELECT db THEN your command") } index, err := strconv.Atoi(hack.String(c.args[0])) if err != nil { - return fmt.Errorf("invalid db for XUSE, err %v", err) + return fmt.Errorf("invalid db for XSELECT, err %v", err) } db, err := c.app.ldb.Select(index) if err != nil { - return fmt.Errorf("invalid db for XUSE, err %v", err) + return fmt.Errorf("invalid db for XSELECT, err %v", err) } c.db = db diff --git a/server/cmd_server_test.go b/server/cmd_server_test.go index 636b90e..ca283dc 100644 --- a/server/cmd_server_test.go +++ b/server/cmd_server_test.go @@ -5,14 +5,14 @@ import ( "testing" ) -func TestXuse(t *testing.T) { +func TestXSelect(t *testing.T) { c1 := getTestConn() defer c1.Close() c2 := getTestConn() defer c2.Close() - _, err := c1.Do("XUSE", "1", "THEN", "SET", "tmp_select_key", "1") + _, err := c1.Do("XSELECT", "1", "THEN", "SET", "tmp_select_key", "1") if err != nil { t.Fatal(err) } @@ -22,7 +22,7 @@ func TestXuse(t *testing.T) { t.Fatal(err) } - n, _ := goredis.Int(c2.Do("XUSE", "1", "THEN", "GET", "tmp_select_key")) + n, _ := goredis.Int(c2.Do("XSELECT", "1", "THEN", "GET", "tmp_select_key")) if n != 1 { t.Fatal(n) }