diff --git a/ledis/cmd_kv.go b/ledis/cmd_kv.go index 754fb95..877b5b5 100644 --- a/ledis/cmd_kv.go +++ b/ledis/cmd_kv.go @@ -137,7 +137,7 @@ func decrbyCommand(c *client) error { return err } - if n, err := c.db.DecrBy(c.args[0], -delta); err != nil { + if n, err := c.db.DecrBy(c.args[0], delta); err != nil { return err } else { c.writeInteger(n) diff --git a/ledis/t_kv.go b/ledis/t_kv.go index bf273fb..b4c27f9 100644 --- a/ledis/t_kv.go +++ b/ledis/t_kv.go @@ -51,7 +51,7 @@ func (db *DB) Decr(key []byte) (int64, error) { } func (db *DB) DecrBy(key []byte, decrement int64) (int64, error) { - return db.incr(key, decrement) + return db.incr(key, -decrement) } func (db *DB) Del(keys [][]byte) (int64, error) {