diff --git a/v2/commands.go b/v2/commands.go index ef666dd..76c13d1 100644 --- a/v2/commands.go +++ b/v2/commands.go @@ -1165,3 +1165,11 @@ func (c *Client) ScriptLoad(script string) *StringCmd { c.Process(req) return req } + +//------------------------------------------------------------------------------ + +func (c *Client) DebugObject(key string) *StringCmd { + req := NewStringCmd("DEBUG", "OBJECT", key) + c.Process(req) + return req +} diff --git a/v2/redis_test.go b/v2/redis_test.go index bb49ccd..269e0af 100644 --- a/v2/redis_test.go +++ b/v2/redis_test.go @@ -2900,14 +2900,14 @@ func (t *RedisTest) TestScriptingScriptLoad(c *C) { c.Assert(scriptLoad.Val(), Equals, "6b1bf486c81ceb7edf3c093f4c48582e38c0e791") } -func (t *RedisTest) TestNewScript(c *C) { +func (t *RedisTest) TestScriptingNewScript(c *C) { s := redis.NewScript("return 1") run := s.Run(t.client, nil, nil) c.Assert(run.Err(), IsNil) c.Assert(run.Val(), Equals, int64(1)) } -func (t *RedisTest) TestEvalAndPipeline(c *C) { +func (t *RedisTest) TestScriptingEvalAndPipeline(c *C) { pipeline := t.client.Pipeline() s := redis.NewScript("return 1") run := s.Eval(pipeline, nil, nil) @@ -2917,7 +2917,7 @@ func (t *RedisTest) TestEvalAndPipeline(c *C) { c.Assert(run.Val(), Equals, int64(1)) } -func (t *RedisTest) TestEvalShaAndPipeline(c *C) { +func (t *RedisTest) TestScriptingEvalShaAndPipeline(c *C) { s := redis.NewScript("return 1") c.Assert(s.Load(t.client).Err(), IsNil) @@ -2931,6 +2931,24 @@ func (t *RedisTest) TestEvalShaAndPipeline(c *C) { //------------------------------------------------------------------------------ +func (t *RedisTest) TestCmdDebugObject(c *C) { + { + debug := t.client.DebugObject("foo") + c.Assert(debug.Err(), Not(IsNil)) + c.Assert(debug.Err().Error(), Equals, "ERR no such key") + } + + { + t.client.Set("foo", "bar") + debug := t.client.DebugObject("foo") + c.Assert(debug.Err(), IsNil) + c.Assert(debug.Val(), FitsTypeOf, "") + c.Assert(debug.Val(), Not(Equals), "") + } +} + +//------------------------------------------------------------------------------ + func (t *RedisTest) BenchmarkRedisPing(c *C) { for i := 0; i < c.N; i++ { if err := t.client.Ping().Err(); err != nil {