Skip to content

Commit

Permalink
Support Redis PING command
Browse files Browse the repository at this point in the history
Closes #22
  • Loading branch information
artyom committed Jun 29, 2020
1 parent c9ffe3d commit ac6fa90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/bitmapist/bitmapist.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (s *Server) Register(srv *red.Server) {
srv.Handle("scan", s.handleScan)
srv.Handle("info", s.handleInfo)
srv.Handle("select", handleSelect)
srv.Handle("ping", handlePing)
srv.Handle("ttl", s.handleTTL)
srv.Handle("pttl", s.handlePTTL)
srv.Handle("expire", s.handleExpire)
Expand Down Expand Up @@ -1134,6 +1135,16 @@ func handleSelect(r red.Request) (interface{}, error) {
}
}

func handlePing(r red.Request) (interface{}, error) {
if len(r.Args) > 1 {
return nil, red.ErrWrongArgs
}
if len(r.Args) == 0 {
return "PONG", nil
}
return r.Args[0], nil
}

// Logger is a set of methods used to log information. *log.Logger implements
// this interface.
type Logger interface {
Expand Down
2 changes: 2 additions & 0 deletions internal/bitmapist/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func TestAgainstRedis(t *testing.T) {
defer cleanupRedis()

cmds := []string{
"ping",
"ping hello",
"multi",
"setbit foo 10 1",
"setbit foo 7 1",
Expand Down

0 comments on commit ac6fa90

Please sign in to comment.