diff --git a/redis.go b/redis.go index 11ef9ce..3e78c85 100644 --- a/redis.go +++ b/redis.go @@ -17,6 +17,10 @@ func (rc RedisCmd) MarshalJSON() ([]byte, error) { return []byte(`"` + rc.String() + `"`), nil } +func (rc RedisCmd) MarshalBinary() ([]byte, error) { + return rc.MarshalJSON() +} + const ( RedisCommandExists RedisCmd = "EXISTS" RedisCommandTTL RedisCmd = "TTL" diff --git a/redis_test.go b/redis_test.go index 1b91860..932321b 100644 --- a/redis_test.go +++ b/redis_test.go @@ -30,4 +30,9 @@ func TestRedisCmd_String(t *testing.T) { So(err, ShouldBeNil) So(string(jsonData), ShouldEqual, `["SET"]`) }) + Convey("redis cmd MarshalBinary", t, func() { + str, err := RedisCommandSet.MarshalBinary() + So(err, ShouldBeNil) + So(string(str), ShouldEqual, `"SET"`) + }) }