Add debug object command.

This commit is contained in:
Vladimir Mihailenco 2014-01-06 13:46:10 +02:00
parent 2fd136fe6c
commit 8452fccfb8
2 changed files with 29 additions and 3 deletions

View File

@ -1165,3 +1165,11 @@ func (c *Client) ScriptLoad(script string) *StringCmd {
c.Process(req) c.Process(req)
return req return req
} }
//------------------------------------------------------------------------------
func (c *Client) DebugObject(key string) *StringCmd {
req := NewStringCmd("DEBUG", "OBJECT", key)
c.Process(req)
return req
}

View File

@ -2900,14 +2900,14 @@ func (t *RedisTest) TestScriptingScriptLoad(c *C) {
c.Assert(scriptLoad.Val(), Equals, "6b1bf486c81ceb7edf3c093f4c48582e38c0e791") c.Assert(scriptLoad.Val(), Equals, "6b1bf486c81ceb7edf3c093f4c48582e38c0e791")
} }
func (t *RedisTest) TestNewScript(c *C) { func (t *RedisTest) TestScriptingNewScript(c *C) {
s := redis.NewScript("return 1") s := redis.NewScript("return 1")
run := s.Run(t.client, nil, nil) run := s.Run(t.client, nil, nil)
c.Assert(run.Err(), IsNil) c.Assert(run.Err(), IsNil)
c.Assert(run.Val(), Equals, int64(1)) c.Assert(run.Val(), Equals, int64(1))
} }
func (t *RedisTest) TestEvalAndPipeline(c *C) { func (t *RedisTest) TestScriptingEvalAndPipeline(c *C) {
pipeline := t.client.Pipeline() pipeline := t.client.Pipeline()
s := redis.NewScript("return 1") s := redis.NewScript("return 1")
run := s.Eval(pipeline, nil, nil) run := s.Eval(pipeline, nil, nil)
@ -2917,7 +2917,7 @@ func (t *RedisTest) TestEvalAndPipeline(c *C) {
c.Assert(run.Val(), Equals, int64(1)) c.Assert(run.Val(), Equals, int64(1))
} }
func (t *RedisTest) TestEvalShaAndPipeline(c *C) { func (t *RedisTest) TestScriptingEvalShaAndPipeline(c *C) {
s := redis.NewScript("return 1") s := redis.NewScript("return 1")
c.Assert(s.Load(t.client).Err(), IsNil) 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) { func (t *RedisTest) BenchmarkRedisPing(c *C) {
for i := 0; i < c.N; i++ { for i := 0; i < c.N; i++ {
if err := t.client.Ping().Err(); err != nil { if err := t.client.Ping().Err(); err != nil {